Home > Software engineering >  how to get a data from another data in python json
how to get a data from another data in python json

Time:09-01

This is the response I get from the server:

[{"status": "OK", "data":[{"Number":"9358925074","Name":"mark","Family":"tomson"}]}]

and if I want to get the Name value from the response, what can I do? can someone make a example in python?

CodePudding user response:

You can do this.

>>> data = [{"status": "OK", "data":[{"Number":"9358925074","Name":"mark","Family":"tomson"}]}]
>>> data[0]['data'][0]['Name']
'mark'

output: 'mark'

CodePudding user response:

This worked for me:

data = json.loads(j.content.decode())
for d in data:
    pass
name = (d['data'][0]['Number'])
print(name)

output:

9358925074
  • Related