JObject.Parse modifies end of floating point values

@Ilija Dimov is correct–JSON.NET parses JSON floats as doubles by default. If you still want to use JObject instead of creating a full blown POCO for deserialization, you can use a JsonTextReader and set the FloatParseHandling option: var reader = new JsonTextReader(new StringReader(clientString)); reader.FloatParseHandling = FloatParseHandling.Decimal; JObject obj = JObject.Load(reader); Console.WriteLine(obj[“max”].Value<decimal>()); // 1214.704958677686

JSON.Net – Change $type field to another name?

http://json.codeplex.com/workitem/22429 “I would rather keep $type hard coded and consistent.” Consistent with what I wonder? http://json.codeplex.com/workitem/21989 I would rather not – I think this is too specific to me and I don’t want to go overboard with settings. At some point I will probably implement this – http://json.codeplex.com/workitem/21856 – allowing people to read/write there own … Read more

JSON.net ContractResolver vs. JsonConverter

Great question. I haven’t seen a clear piece of documentation that says when you should prefer to write a custom ContractResolver or a custom JsonConverter to solve a particular type of problem. They really do different things, but there is some overlap between what kinds of problems can be solved by each. I’ve written a … Read more

Json.NET get nested jToken value

You can use SelectToken() to select a token from deep within the LINQ-to-JSON hierarchy for deserialization. In two lines: var token = jObj.SelectToken(“response.docs”); var su = token == null ? null : token.ToObject<Solr_User []>(); Or in one line, by conditionally deserializing a null JToken when the selected token is missing: var su = (jObj.SelectToken(“response.docs”) ?? … Read more

JSON.NET: Why Use JToken–ever?

From the standard, JSON is built out of the following five types of token: object: an unordered set of name/value pairs. array: an ordered collection of values. value: a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested. string number. … Read more