Answers for "json from string python"

13

python json string to object

import json

x =  '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)

print(y["age"])
Posted by: Guest on May-14-2020
1

json load

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)
Posted by: Guest on October-27-2020
0

json.loads

>>> import json
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
['foo', {'bar': ['baz', None, 1.0, 2]}]
>>> json.loads('"\"foo\bar"')
'"foox08ar'
>>> from io import StringIO
>>> io = StringIO('["streaming API"]')
>>> json.load(io)
['streaming API']
Posted by: Guest on September-15-2020

Code answers related to "json from string python"

Python Answers by Framework

Browse Popular Code Answers by Language