Friday, 15 July 2011

json deserialization - ASP.NET Web API Handles Two Integers Differently -



json deserialization - ASP.NET Web API Handles Two Integers Differently -

i have model in web api project accepts 2 integers:

public int parentid { get; set; } public int childid { get; set; }

while testing api, tested sending crazy big numbers (like do) in json message:

{ parentid: 333333333333333333333333333333333333333, childid: 1 }

in above case, parentid becomes 0. happy days.

in next case, childid passed exact same crazy big number, whole model ends null.

{ parentid: 1, childid: 333333333333333333333333333333333333333 }

why not cause childid become 0 parentid did?

you can solve issue appending comma. neat</sarcasm>.

{ parentid: 2, childid: 333333333333333333333333333333333333333, }

so indeed deserializer bug noted @djikay in comments above.

update: issue has been fixed: https://github.com/jamesnk/newtonsoft.json/issues/315

asp.net-web-api json-deserialization

No comments:

Post a Comment