JSON Decoder with strict=False

I had a lot of trouble decoding a json object that had all kind of special characters, nextline characters (\n), carriage returns (\r). On doing some initial search, I saw solutions where people recommended replacing \n with \\n, etc. I started with that and it worked, but down the path I found that there were many more characters that I had to now replace manually. Then one of my colleague recommended to use a specific JSON decoder with strict=False option. I tried that and it did what I was looking for. Wondering why this method is not recommended on the other blogs, stackoverflow over json.loads.

import json
dictData = json.JSONDecoder(strict=False).decode(jsonData)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s