string python json para objeto
import json
x = '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)
print(y["age"])
Anxious Ant
import json
x = '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)
print(y["age"])
jsonStr = json.dumps(myobject.__dict__)
# a Python object (dict):
x = {
"name": "John",
"age": 30,
"city": "New York"
}
# convert into JSON:
y = json.dumps(x)
# if you're not using a class for your json you can just do this
jsonStr = json.dumps(jsn)
# if you want to serialize a class then you need to add the __dict__
jsonStr = json.dumps(jsn.__dict__)