I've been looking for a better json library for my Unity project. I need to be serialize using a different name other than the property name, deserialize dictionaries containing arbitrary user defined content and ignore null fields in serialization. I've added the .dll (net20) for Json.NET v12.0.1 to my Unity project and it seems to work fine in my (limited) testing.
public class Foo
{
[JsonProperty("baz", NullValueHandling = NullValueHandling.Ignore)]
public Bar Baz{ get; set; }
[JsonProperty("quux", NullValueHandling = NullValueHandling.Ignore)]
public Qux Quux{ get; set; }
}
public class Corge: Dictionary<string, JObject>
{
//whatever the user wants to send will come back from the REST call
}
public void OnResponse(string responseJson)
{
var corge = JsonConvert.DeserializeObject<Corge>(responseJson);
var name = corge["name"].ToString();
}
Before I completely refactor my project will there be any limitations using Json.NET in Unity and publishing to different platforms? Would using dynamic work better than extending Dictionary?