Answers for "json converter python"

2

Convert from JSON to Python

import json

# some JSON:
x =  '{ "name":"John", "age":30, "city":"New York"}'

# parse x:
y = json.loads(x)

# the result is a Python dictionary:
print(y["age"])
Posted by: Guest on February-01-2021
0

json decode py

>>> 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 May-17-2020

Python Answers by Framework

Browse Popular Code Answers by Language