Skip to content

Is there any way to search through a JSON object for a value? [closed]

I’m currently working on a ROBLOX Integrated discord bot with and have stumbled into an issue with checking if the user is in a group. I have already got a table of all groups and ranks, but have no clue how to iterate through it. The JSON structure is similar to as follows:


In a real example, there would be more than just two groups but I was wondering if there was any way to iterate through and check if the group ID is equal to 1 and then get the role associated with the group? I couldn’t find a solution anywhere else.


So basically, data is a key and the bracket block is a value. That value is a list of dictionaries and the group key corresponds to another dictionary this one containing the id.

So if the json is stored in a variable called x then doing


will get one of them. A loop would be something like

for i in range(len(x[‘data’])):
user_id = x[‘data’][i-1][‘group’][‘id’]
if user_id == ‘1’:

Hopefully this helps. The json would need to be correct though!