I have a model in my Web API project that accepts two integers:
public int ParentId { get; set; }
public int ChildId { get; set; }
While testing the API, I tested sending crazy big numbers (like you do) in the JSON message:
{
ParentId: 333333333333333333333333333333333333333,
ChildId: 1
}
In the above case, the ParentId becomes 0. Happy days.
In the following case, where the ChildId is passed with the exact same crazy big number, the whole model ends up null.
{
ParentId: 1,
ChildId: 333333333333333333333333333333333333333
}
Why does this not simply cause ChildId to become 0 as the ParentId did?
You can solve this issue by appending a comma. Neat</sarcasm>.
{
ParentId: 2,
ChildId: 333333333333333333333333333333333333333,
}
So it does indeed look like a deserializer bug as noted by @djikay in the comments above.
Update: The issue has been fixed: https://github.com/JamesNK/Newtonsoft.Json/issues/315
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With