The format JSON lines (http://jsonlines.org/) is pretty widely used, but is an extension of JSON itself. Basically, it's the idea that you can put one object per physical line to allow incremental reading or spending of objects.
It's a good idea, and I think the `json` module should support it. But it definitely doesn't belong in `pathlib`. On Mar 27, 2017 3:36 PM, "Paul Moore" <p.f.mo...@gmail.com> wrote: > On 27 March 2017 at 17:43, Bruce Leban <br...@leban.us> wrote: > > the ability to read one json object from the input rather than reading > the > > entire input > > Is this a well-defined idea? From a quick read of the JSON spec (which > is remarkably short on details of how JSON is stored in files, etc) > the only reference I can see is to a "JSON text" which is a JSON > representation of a single value. There's nothing describing how > multiple values would be stored in the same file/transmitted in the > same stream. It's not unreasonable to assume "read one object, then > read another" but without an analysis of the grammar, it's not 100% > clear if the grammar supports that (you sort of have to assume that > when you hit "the end of the object" you skip some whitespace then > start on the next - but the spec doesn't say anything like that. > Alternatively, it's just as reasonable to assume that > json.load/json.loads expect to be passed a single "JSON text" as > defined by the spec. > > If the spec was clear on how multiple objects in a single stream > should be handled, then yes the json module should support that. But > without anything explicit in the spec, it's not as obvious. What do > other languages do? > > Paul > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/