def json2py(jsonstr):

    from xml.sax.saxutils import unescape

    if not isinstance(jsonstr, str):
        return jsonstr
    try:
        jsonstr = unescape(jsonstr, {"u'": '"'})
        jsonstr = unescape(jsonstr, {"'": '"'})
        python_structure = json.loads(jsonstr)
    except ValueError:
        _debug("ERROR: attempting to convert %s using modules/s3db/survey/json2py.py" % (jsonstr))
        return jsonstr
    else:
        return python_structure

# -----------------------------------------------------------------------------
Utility function to convert a string in json to a python structure
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/json2py