lovasoa / bad_json_parsers

Exposing problems in json parsers of several programming languages.
MIT License
366 stars 25 forks source link

.NET JSON parser methodology #25

Open daiplusplus opened 4 years ago

daiplusplus commented 4 years ago

Newtonsoft.Json can parse JSON in different ways, both with and without using a String representation and this will give you different results (e.g. a String cannot exceed 1,073,741,824 characters (due to the 2GiB single object size limit and the fact String always uses UTF-16) so that's an upper-limit when using JsonConvert.DeserializeObject<T>(String) but you should be able to read an input stream exceeding that limit using JsonTextReader and passing that into DeserializeObject.

Additionally, the first-party JSON parser that shipped with WCF 3.5 (System.Runtime.Serialization.Json is built on the XML parser, which means it inherits the configurable nested object depth-limit - and I've seen this is not well understood in the .NET community - so just throwing that out there.

lovasoa commented 4 years ago

That is very interesting, thank you! Would you be interested in adding .net to our travis CI so that we can test these two parsers?