Skip to content

Instantly share code, notes, and snippets.

@gon250
Created September 30, 2015 15:51
Show Gist options
  • Select an option

  • Save gon250/cb0dbeb1162f6e43dff1 to your computer and use it in GitHub Desktop.

Select an option

Save gon250/cb0dbeb1162f6e43dff1 to your computer and use it in GitHub Desktop.

Revisions

  1. gon250 created this gist Sep 30, 2015.
    21 changes: 21 additions & 0 deletions GetJsonDeserializer.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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();
    }
    }