MCPcopy Create free account
hub / github.com/Boris-code/feapder / get_json

Function get_json

feapder/utils/tools.py:945–976  ·  view source on GitHub ↗

@summary: 取json对象 --------- @param json_str: json格式的字符串 --------- @result: 返回json对象

(json_str)

Source from the content-addressed store, hash-verified

943
944##################################################
945def get_json(json_str):
946 """
947 @summary: 取json对象
948 ---------
949 @param json_str: json格式的字符串
950 ---------
951 @result: 返回json对象
952 """
953
954 try:
955 return json.loads(json_str) if json_str else {}
956 except Exception as e1:
957 try:
958 json_str = json_str.strip()
959 json_str = json_str.replace("'", '"')
960 keys = get_info(json_str, "(\w+):")
961 for key in keys:
962 json_str = json_str.replace(key, '"%s"' % key)
963
964 return json.loads(json_str) if json_str else {}
965
966 except Exception as e2:
967 log.error(
968 """
969 e1: %s
970 format json_str: %s
971 e2: %s
972 """
973 % (e1, json_str, e2)
974 )
975
976 return {}
977
978
979def jsonp2json(jsonp):

Callers 2

dumps_jsonFunction · 0.85
get_json_valueFunction · 0.85

Calls 2

get_infoFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected