Parse JSON Safely

Parse JSON with a fallback value returned if parsing fails.

Code

Utilities
import json
try:
    return json.loads(jsonStr)
except:
return     return json.loads(fallback)

Parameters

JSON string to parse.

Fallback value if parsing fails (as JSON).

Server

More Python Snippets