I am facing an issue while decoding json string using json.loads

Tim Roberts timr at probo.com
Thu Dec 27 06:07:31 CET 2012


sajuptpm <sajuptpm at gmail.com> wrote:
>
>I am facing an issue while decoding json string using json.loads(jstring).
>Its working, if i do json.dumps(eval(jstring)) before json.loads(jstring).
>I could not figure out the issue. I want to avoide use of "eval" here.

The problem is that your string contains two instances of an escaped right
bracket  \]  .  That's not one of the characters you're allowed to escape
in JSON.  The rules are very strict.  There are only 8 allowed escape
codes, plus the \u#### construct.

Note that you cannot just replace \] with ], because your string also
contains one instance of \\] .

Who is doing the JSON encoding?  It appears to be doing it incorrectly.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list