[pre-SRFI] JSON Amirouche Boubekki (01 Jan 2020 14:04 UTC)
Re: [pre-SRFI] JSON Amirouche Boubekki (01 Jan 2020 21:11 UTC)
Re: [pre-SRFI] JSON Lassi Kortela (02 Jan 2020 10:46 UTC)
Re: [pre-SRFI] JSON Amirouche Boubekki (02 Jan 2020 12:07 UTC)
Re: [pre-SRFI] JSON Duy Nguyen (02 Jan 2020 09:13 UTC)
Re: [pre-SRFI] JSON Lassi Kortela (02 Jan 2020 10:03 UTC)
Re: [pre-SRFI] JSON Amirouche Boubekki (02 Jan 2020 12:23 UTC)
Re: [pre-SRFI] JSON Amirouche Boubekki (02 Jan 2020 22:05 UTC)
Re: [pre-SRFI] JSON Duy Nguyen (06 Jan 2020 01:20 UTC)

Re: [pre-SRFI] JSON Amirouche Boubekki 02 Jan 2020 12:07 UTC

Le jeu. 2 janv. 2020 à 10:46, Lassi Kortela <xxxxxx@lassi.io> a écrit :

> > The problem that I tried to solve, that is really fun, is to not rely
> > on the stack to parse any JSON.  That allows the following tests to
> > pass:
> >
> >    n_structure_100000_opening_arrays.json
> >
> >    i_structure_500_nested_arrays.json
> >
> > The first with a n prefix, will not segfault (or whatever) and the
> > second just works even if it is unspecified.
>
> Thanks for doing thorough work and going through that test suite.

By the way, the reporting done at

  https://raw.githubusercontent.com/nst/JSONTestSuite/master/results/pruned_results.png

One can seemingly think that Python parser somehow pass those tests
(second and third line). In pratice, the result is disappointing:

In [1]: import json
In [2]: json.load(open('n_structure_100000_opening_arrays.json'))
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
[...]
RecursionError: maximum recursion depth exceeded while decoding a JSON
array from a unicode string

In [3]: json.load(open('i_structure_500_nested_arrays.json'))
Out[3]: ---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
[...]
RecursionError: maximum recursion depth exceeded while calling a Python object

The consequence of that behavior is that when you want to parse JSON
from an untrusted source (which is very likely when you expose a
service to the Internet), you need to wrap json.load inside try/except
(Python's guard). At least, that error does not happen with the parser
I am working on.

--
Amirouche ~ https://hyper.dev