Xamarin Forms unable to convert the response Json to Objects using Newtonsoft.Json

Ganesh.4229Ganesh.4229 USMember ✭✭

Hi All,

I am facing the issue during Json convertion using Newtonsoft.Json.dll , which is throwing a fallowing exception.

System.TypeLoadException: Failure has occurred while loading a type.
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator (System.Type createdType) [0x00005] in :0
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00093] in :0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00007] in :0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00100] in :0
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00029] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe (System.Type type) [0x0000b] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x0000e] in :0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00053] in :0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in :0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in :0

Can Any one help me out .

Thank you,

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Post your json

  • Ganesh.4229Ganesh.4229 USMember ✭✭
    edited July 2017

    Hi Alessandro, Any Json its throwing the above exception, the sample code is like below

                var response = "{\"id\": 0, \"name\": \"sinol\"}";
                Model.SampleJson result = JsonConvert.DeserializeObject<Model.SampleJson>(response);
                Debug.WriteLine("Response String is >> " + result.ToString());
    
  • Ganesh.4229Ganesh.4229 USMember ✭✭

    Android its working fine, iOS is phasing the above problem.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    have you add the package to iOS project?

  • Ganesh.4229Ganesh.4229 USMember ✭✭

    Which Package ?

Sign In or Register to comment.