In Python, is there a way to check if a string is valid JSON before trying to parse it?
For example working with things like the Facebook Graph API, sometimes it r
You can try to do json.loads(), which will throw a ValueError if the string you pass can't be decoded as JSON.
json.loads()
ValueError
In general, the "Pythonic" philosophy for this kind of situation is called EAFP, for Easier to Ask for Forgiveness than Permission.