Eric.L Eric.L - 1 year ago 94
JSON Question

How do I call specific json data?

i'm currently working on a project that involves getting data from RiotGames API and would apprciate some help in this problem I can't seem to solve.

The code:

import requests
r = requests.get(url="")
json_data = r.json()
get_summoner_data = (json_data["champions"])

And this is the response


So the respone is basically data of the players performance with different champions, in this case defined by their id's.

But let's say someone is playing the champion with the id 111, now I want to get all data connected to that id and then be able to print out certain parts ex: MaxDeaths and MaxGold.

But if no data for that id is found I would have a message like "Data not found".

As you can see here there is data for the champion-id 111, but how do I call to get only that data?

Side note for better understading:
A player is in a game with 10 other players, 5 on each team. Every single person is playing different champions. I want to see if the player has any prior experience with that champion (All that data), and will therefore check if the champion-id is in the summary. If it is, I will use that data to make some sort of performance analyse.

Answer Source
for i in json_data["champions"]:
  if i["id"]=="111":
  print("not found")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download