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

Deron Meranda deron.meranda at gmail.com
Thu Mar 20 23:38:28 CET 2008


On Thu, Mar 20, 2008 at 6:03 PM, Bob Ippolito <bob at redivi.com> wrote:
> On Thu, Mar 20, 2008 at 1: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 very cool, but it's not reproducible. If you published the
>  code that you used then it would help everyone out considerably.

Yes, I will try to do that.  I just need to clean it up a bit so it's
a bit less manual.

> For example, with simplejson 1.7.5 I'm unable to reproduce the problems
>  you're experiencing with
>  http://deron.meranda.us/python/comparing_json_modules/strings in Table
>  1 (other than UserString of course).

Do you mean tests 1-12 and 1-13 where simepljson is seemingly
not \u escaping U+001A through U+001F ?

I think my table might be confusing.  In those sets of tests I'm looking at
the JSON after its been converted into UTF-8 (because while it is
sitting in memory as a "unicode" string, its not technically JSON).
I talk about that on the next page (Unicode), but that's not the same
order you read things in...my fault; I'll try to rewrite that a bit so its
clearer.

Anyway, to get JSON in UTF-8, I'm calling it like this:

  simplejson.dumps( ["\x1a"], ensure_ascii=False ).encode('utf8')

which on my system outputs this:   '["\x1a"]'
rather than this:  '["\\u001a"]'

If I change the ensure_ascii to its default of True, then I do get
the correct results.

Interestingly it works correctly either way for all characters
at or less than U+0019.

So is it just the way I'm calling it (perhaps not as intended),
or do we still see a difference between your system and mine?


I'll try to get some test framework code up within the next day.
-- 
Deron Meranda


More information about the Web-SIG mailing list