Every line of 'python parse json' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
9 def parse_json(content): 10 parsed = json.loads(content) 11 assert isinstance(parsed, (list, dict)), f'Expecting list or dict; got {parsed!r}' 12 return parsed
113 def _parse_json(string): 114 try: 115 result = json.loads(string) 116 except: # noqa 117 # Fall back to the standard parser if ujson fails 118 result = standard_json.loads(string) 119 return result
46 def _parse_json(s): 47 ' parse str into JsonDict ' 48 49 def _obj_hook(pairs): 50 ' convert json object to python object ' 51 o = JsonDict() 52 for k, v in pairs.iteritems(): 53 o[str(k)] = v 54 return o 55 return json.loads(s, object_hook=_obj_hook)
5 @staticmethod 6 def parse(str): 7 return json.loads(data);
68 def parse_json(json_string): 69 """Converts a JSON-C string into a Jsonc object. 70 71 Args: 72 json_string: str or unicode The JSON to be parsed. 73 74 Returns: 75 A new Jsonc object. 76 """ 77 78 return _convert_to_jsonc(simplejson.loads(json_string))
68 def parse_json(json_string): 69 """Converts a JSON-C string into a Jsonc object. 70 71 Args: 72 json_string: str or unicode The JSON to be parsed. 73 74 Returns: 75 A new Jsonc object. 76 """ 77 78 return _convert_to_jsonc(simplejson.loads(json_string))
139 def test_json_simple(self): 140 self.assertEqual(self.context.parse_json("42"), 42)
191 def _parse_json(source, json_path_expr=None): 192 if not source: 193 _logger.debug('Unable to parse JSON from empty source, return empty.') 194 return {} 195 196 if json_path_expr: 197 _logger.debug( 198 'Try to extract JSON from source with JSONPATH expression: %s, ', 199 json_path_expr 200 ) 201 source = json_path(source, json_path_expr) 202 203 elif isinstance(source, six.string_types): 204 source = json.loads(source) 205 206 return source
13 def parse(text): 14 reviver = arguments[1] 15 s = text.to_string().value 16 try: 17 unfiltered = json.loads(s) 18 except: 19 raise this.MakeError('SyntaxError', 20 'Could not parse JSON string - Invalid syntax') 21 unfiltered = to_js(this, unfiltered) 22 if reviver.is_callable(): 23 root = this.Js({'': unfiltered}) 24 return walk(root, '', reviver) 25 else: 26 return unfiltered
352 def json2dict(s): 353 if isinstance(s, dict): 354 return s 355 s = str(s) 356 d = {} 357 try: 358 d = json.loads(s) 359 except: 360 try: 361 d = eval(s) 362 except: 363 s = s.replace('true', 'True').replace('false', 'False').replace( 364 'null', 'None').replace('none', 'None') 365 d = eval(s) 366 return d