Loki-Astari / JsonBenchmark

Json benchmark based on nativejson-benchmark
Other
25 stars 6 forks source link

Add test for maximal nesting of arrays/objects #5

Open nlohmann opened 4 years ago

nlohmann commented 4 years ago

Almost all JSON parsers have limitations in the maximal nesting of arrays or objects. While

[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]

certainly will break no library any more, having the same input with a few thousand more [] will. It would be great to know the limits of the libraries.

Loki-Astari commented 4 years ago

I don't see much real value in this.
It's more of an implementation oddity on who can support the deepest nested array structure. In real life I would not expect to see 20 level nested array (or anything like that). IF you can support 20 levels you will be able to support any real life json objects that you find in the wild.

nlohmann commented 4 years ago

I disagree that there is no value in it, because it is also a security issue if you can crash your parser with just a few bytes yielding a stack overflow.

Loki-Astari commented 4 years ago

OK. I sort of agree with that.