[Python-ideas] iterator/stream-based JSON API
Andrew Barnert
abarnert at yahoo.com
Mon Jun 3 04:53:58 CEST 2013
From: Daniel Holth <dholth at gmail.com>
Sent: Sunday, June 2, 2013 7:11 PM
> When will the stdlib get a decent iterator/stream-based JSON API? For
> example automated packaging tools may be parsing a lot of JSON but
> ignoring most of it, and it would be lovely to say "if key not in
> interesting: skip_without_parsing()".
This sounds very interesting, but I'm not sure I'm thinking of the same thing you are.
First, are you looking for a SAX-style API? Or something more like fts (http://man7.org/linux/man-pages/man3/fts.3.html) but with a nicer (iterator-plus-methods) syntax? Or… can you just post a complete simple example of what you'd like it to look like?
> Or to go straight from parse to> domain objects without putting the whole thing in an intermediate
> dict.
What does this part mean? You mean you want an opaque object with a DOM API, or an XPath-style accessor, instead of a native Python object? If so, why? Do you think having a dict hidden inside an opaque object, or using some other hash table implementation, is going to save space over just having a dict? Or would you prefer to write doc.find_element("my_key").find_element("my_other_key").find_element(3) or doc.find('//my_key/my_other_key[3]") instead of doc["my_key"]["my_other_key"][3]?
More information about the Python-ideas
mailing list