Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get certain data from json
#3
(Jan-06-2018, 02:00 PM)mpd Wrote: The response is a string, you can use the json module to "load" the string as an object:
Bye the look of his data and response this is already done.
I guess he use a library or Requests to get the data,they will return data same as using json.loads()(return a Python dictionary).

@kappa123 what you get back is a Python dictionary with mixed in list.
This is common when get json back.

So if i just put you code in variable data data = { '_total':112, ....
Can use it to get data out.
>>> data['streams'][1]['channel']
{'_id': 49754222,
 'broadcaster_language': 'en',
 'broadcaster_type': '',
 'created_at': '2013-10-04T04:40:06.886355Z',
 'description': "Whats up all, I'm Hon Yolo and welcome to the community. We "
                'are a family here so come in and enjoy the fun!',
 'display_name': 'HonYolo',
 'followers': 8819,
 'game': 'Grand Theft Auto V',
 'language': 'en',
 'logo': 'https://static-cdn.jtvnw.net/jtv_user_pictures/347ae60c8343326d-profile_image-300x300.png',
 'mature': True,
 'name': 'honyolo',
 'partner': False,
 'profile_banner': 'https://static-cdn.jtvnw.net/jtv_user_pictures/honyolo-profile_banner-4e9846d200e548d4-480.png',
 'profile_banner_background_color': '#000000',
 'status': 'Honathan Yolo - 24H of Honathan - NoPixel GTA RP\n\n',
 'updated_at': '2018-01-06T13:35:18.174199Z',
 'url': 'https://www.twitch.tv/honyolo',
 'video_banner': 'https://static-cdn.jtvnw.net/jtv_user_pictures/018e3a2d1044db68-channel_offline_image-1920x1080.png',
 'views': 55054}

>>> data['streams'][1]['channel']['display_name']
'HonYolo'
So you need to search for hi and/or hey and/or hell in dictionary,
and then return display_name that say this.
Reply


Messages In This Thread
get certain data from json - by kappa123 - Jan-06-2018, 01:54 PM
RE: get certain data from json - by mpd - Jan-06-2018, 02:00 PM
RE: get certain data from json - by snippsat - Jan-06-2018, 02:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 391 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  Read nested data from JSON - Getting an error marlonbown 5 1,517 Nov-23-2022, 03:51 PM
Last Post: snippsat
  Reading Data from JSON tpolim008 2 1,187 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  Convert nested sample json api data into csv in python shantanu97 3 3,038 May-21-2022, 01:30 PM
Last Post: deanhystad
  Struggling with Juggling JSON Data SamWatt 7 2,059 May-09-2022, 02:49 AM
Last Post: snippsat
  json api data parsing elvis 0 973 Apr-21-2022, 11:59 PM
Last Post: elvis
  Capture json data JohnnyCoffee 0 1,269 Nov-18-2021, 03:19 PM
Last Post: JohnnyCoffee
  Serializing Python data Correctly (JSON) JgKSuperstar 4 2,240 Nov-04-2021, 07:31 PM
Last Post: JgKSuperstar
  How to save json data in a dataframe shantanu97 1 2,217 Apr-15-2021, 02:44 PM
Last Post: klllmmm
  Sort data from JSON file Dummy_in_programming 2 2,525 Jan-04-2021, 06:17 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020