Not everything is being parsed into json?

Ok so in https://replit.com/@BillyHornets/Testv5#main.p what I did was I converted a fairly big API (Like one which has a lot of text) into JSON. However, only a certain part of the API is actually being converted. Although I do suspect that the API webpage might be too big to be converted, it isn’t ideal since it just so happens that the part of the API that I need hasn’t been converted. Would be ideal to know if there’s something I could do to convert that certain part I need

What makes you think not everything is parsed?

It’s not that it makes me think that, when I print it, that specific part isn’t there. Alongside that when I try to use the key’s inside of the not parsed things I get a Keyerror message.

There’s a certain size that can be displayed in console, the rest will be cut off. Try saving it to file to make sure.

To get to a specific key inside of the parsed JSON you may need to go through other keys, depending how structured is the actual JSON.

Yeah, I do go through other keys and it still manages to find a KeyError.
So I’m pretty confused. Also if it helps, it’s a chunk of the start that’s cut off. Not the end.

Would you mind updating code on replit? It currently shows only trying to load both keys from the top level of dictionary, what’s not a structure of that JSON.

Yes, the beginning is cut off in the console.

What do you mean by trying to load both keys from the top level?
If something isn’t updated, this is the code.

import requests

response = requests.get(‘https://api.hypixel.net/player?key=37358e7c-1796-4319-afbe-61b2d6b65d4e&uuid=ba16549a30ae4c3e90a166f514a1534d’)

lolerz = response.json()

lol = lolerz[‘Bedwars’]

winstreak = lolerz[‘winstreak’]

print(winstreak.text)

Taking as an example:

dictionary = {'A': {'B': {'C': 3, 'D': 4}}}

To get value of 'C' it’s needed to get to the appropriate dictionary:

dictionary['A']['B']['C']  # 3
dictionary['C']  # KeyError

Situation here is similar, JSON is can have multiple nested dictionaries or lists.

I already know that and indeed have done it. In my dictionary, ‘winstreak’ (The key I want to access) is inside of ‘Bedwars’.
So what’s the problem?

But where in the whole JSON is the 'Bedwars'? It is nested deeper inside of the structure, the most outer dictionary doesn’t have 'Bedwars' key.

1 Like

Oh… well, I’m really dumb… sorry for that. And thanks for your help!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.