I want to know how to read a specific objects value from within a JSON object.
"worker_01": {
"data": {
"name": "Juan",
"manager": 0,
"weight": 75,
"positions": {
"FOH": 1,
"MOH": 1,
"BOH": 1
}
}
},
I know previously in Node.js
I could read them by doing *.get(worker_01.data.name)*
but python doesn't really allow that. I want to know how do I do something similar to that in python.
Here is my source code.
import json as js
data_json = open('hello.json')
data_worker = js.load(data_json)
for i in data_worker['worker_01']:
print(i)
data_worker['worker_01']['data']['name']
, as a typedata_worker
here is a python dictionary if you useload
, also a bit related: I would suggest usingwith
to open files – Matiiss