JSON Deserialization - String Is Automatically Converted To Int
问题 When I deseiralize the JSON to the C# object below, either using Newtonsoft explicitly or via the model binding mechanism of ASP.NET Web Api, the string id value is automatically converted to int. I would expect it to throw an exception or raise an error as there is a type mismatch. Is this how JSON is supposed to work in the specs? If not, how can I prevent such an automatic conversion? JSON: {"id":"4", "name":"a"} C# model: int id; string name 回答1: This is a feature of Json.NET: when