You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
771 B

import json
mydict = {
"people": [
{
"name": "Bob",
"age": 28,
"weight": 80
},
{
"name": "Anna",
"age": 34,
"weight": 60
},
{
"name": "Charles",
"age": 45,
"weight": 90
},
{
"name": "Daniel",
"age": 21,
"weight": 120
}
]
}
json_string = json.dumps(mydict, indent=2)
def writeJson():
with open("iot/blueprints/utils/json_test.json", 'w') as f:
f.write(json_string)
def readJson():
with open("iot/blueprints/utils/json_test.json", 'r') as f:
json_object = json.loads(f.read())
print(json_object['people'][0]['name'])