def json_loads(data):
"""
It works as json.loads but supporting multiple encodings in the same
string and accepting an `str` parameter that won't be converted to unicode.
:param data: the string to load the objects from
:type data: str
:returns: the corresponding python object result of parsing 'data', this
behaves similarly as json.loads, with the exception of that
returns always `str` instead of `unicode`.
"""
obj = None
with CustomJsonScanner():
# We need to use the cls parameter in order to trigger the code
# that will let us control the string parsing method.
obj = json.loads(data, cls=json.JSONDecoder)
return obj
评论列表
文章目录