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

Gora Mohanty gora at mimirtech.com
Wed Dec 26 08:39:35 CET 2012


On 26 December 2012 12:39, Saju M <sajuptpm at gmail.com> wrote:
> Hi,
>
> 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.
>
>
>
> *######################## Failing without json.dumps(eval(jstring))
> ########################*
>
>
> def format_json_string(self, jstring):
>     """
>     """
>     from pprint import pprint
>     print "===string before urllib.unquote===", pprint(jstring)
>     jstring = urllib.unquote(jstring)##For revert encode change applied in
> the javascript
[...]

urllib.unquote is messing up the JSON. Reverse the
order of unquote, and loads, i.e., do a json.loads on
the original string, and then urllib.unquote the components
that need unquoting.

Regards,
Gora


More information about the BangPypers mailing list