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

1

5

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.

Kurd answered 20/6, 2011 at 6:56 Comment(1)
As answered and accepted, it comes across that OP wanted to know how to load the data. However, there was a deleted answer from OP (it should have been extra information edited into the question) suggesting that the actual problem was with understanding how to use the parsed data - specifically, OP showed already parsed data, and an error message that would result from trying to use that data as a file or filename. Since this is not a completely useless signpost, I edited the duplicate links so that they address both problems. At this point though, the question should probably be deleted.Ascham
W
11

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'
Webworm answered 20/6, 2011 at 6:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.