Skip to content

Instantly share code, notes, and snippets.

@gon250
Created September 30, 2015 15:51
Show Gist options
  • Save gon250/cb0dbeb1162f6e43dff1 to your computer and use it in GitHub Desktop.
Save gon250/cb0dbeb1162f6e43dff1 to your computer and use it in GitHub Desktop.
Deserialize json example
public RootObject GetJsonDeserializer(string json)
{
try
{
JsonDataSession = (RootObject)JsonConvert.DeserializeObject(json, typeof(RootObject), new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto,
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore,
Error = (serializer, err) =>
{
err.ErrorContext.Handled = true;
}
});
return JsonDataSession;
}
catch (Exception ex)
{
return new RootObject();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment