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.

nik2702
  • 93
  • 1
  • 2
  • 8
  • 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. – Karl Knechtel Jul 02 '22 at 01:39

1 Answers1

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'
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358