Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract data from JSON Object in Python? [duplicate]

I am trying to extract data from JSON Object which is returned from the api call for api.trends() [Tweepy] but I am not able to extract the data.

Can anyone give me an example of how to extract data from JSON object. I want to extract the data in tabular form.

Thanks in advance.

like image 710
nik2702 Avatar asked Jun 20 '11 06:06

nik2702


1 Answers

Once you run it though json.loads() it becomes normal Python objects. Simply index it as you would any dict or list.

>>> json.loads('{"foo": 42, "bar": "baz"}')['bar']
'baz'
like image 200
Ignacio Vazquez-Abrams Avatar answered Oct 04 '22 20:10

Ignacio Vazquez-Abrams