close

How to get data from a list Json with python?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to get data from a list Json with python in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to get data from a list Json with python?

  1. How to get data from a list Json with python?

    json_data = [] # your list with json objects (dicts) for item in json_data: for data_item in item['data']: print data_item['name'], data_item['value']

  2. data from a list Json with python

    json_data = [] # your list with json objects (dicts) for item in json_data: for data_item in item['data']: print data_item['name'], data_item['value']

Method 1

json_data = [] # your list with json objects (dicts)

for item in json_data:
    for data_item in item['data']:
        print data_item['name'], data_item['value']

Method 2

Something like

for key, value in json_data.iteritems():
    print key
    if isinstance(value, (list, tuple)):
        for item in value: 
            print item
    if isinstance(value, (dict)):
        for value_key,value_value in value.iteritems(): 
            print value_key,str(value_value)

Can be improved to manage more types and can be made recursive.

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read