[Web-SIG] Time a for JSON parser in the standard library?

John Millikin jmillikin at gmail.com
Thu Mar 20 23:48:08 CET 2008


On Thu, Mar 20, 2008 at 12:37 PM, Deron Meranda <deron.meranda at gmail.com> wrote:
>  I finally sat down and put the five or so top JSON libraries
>  to the test so we can all see what's what.  I've put everything
>  in a report here:
>
>  http://deron.meranda.us/python/comparing_json_modules/
>
This is fantastic. My knowledge of other JSON modules was based mainly
on the comparison page from json.org, and yours is much more complete
and informative.

You could try adding a section to the numbers area about
Arabic/Chinese/whatever numbers, such as U+0661. These are not allowed
in JSON, but are accepted by parsers that use \d regex patterns with
the re.UNICODE flag set.

For strings, I would like to suggest that escaping "/" to "\\/" be
considered the norm, with deviations from this marked on the table.
This is to protect against foolish website authors including JSON
directly using a <script> tag.

I think the RFC allows inclusion of U+000A (newline) in strings
without escaping -- at least, it is not in the range of characters
requiring escaping.

You remark in the page on Unicode that "[encoding] is not a concern
for any of the UTF-[8,16,32] encodings, but it could be if you wanted
ISO-8859-4 for example". However, the RFC specifies that all JSON text
is to be encoded using a Unicode encoding.

I hope you don't mind if I "borrow" your test cases to use in the
jsonlib unit test suite.

And finally, I apologize for slandering demjson. I was not aware that
it had a "strict" mode, and constructed my opinion of it based on its
behavior in "loose" mode.

>  I do think though that if this is targeted for Python 3, that
>  none of the modules really works well.  We should really
>  design an interface that uses the bytes type rather
>  than str for pushing around encoded JSON data.
>
This seems like a module that would be easy enough to have in both 2.6
and 3. The py3k version could have additional enhancements, such as
detecting appropriate serialization formats based on ABCs, but even a
limited version in 2.6 would be more helpful than none at all.


More information about the Web-SIG mailing list