How to read multiple curly brackets with json in python?

Question:

I need a way to read multiple curly brackets in python. I have a test json that has multiple layers of curly brackets and I need to get to the deepest layer. My test json: my json (I need it to return "name". My code isn’t working, but this is what it looks like (not all of it, just the important parts.)

import json 
    
with open(args.mc_path + "launcher_profiles.json", "r+") as profiles:
    data = json.load(profiles)

test = data["profiles": { "053abfb0fb7451c291b9149ea7df88c8": {"name"}}]
print(test)
Asked By: Pogman69

||

Answers:

You can index on nested dictionaries multiple times to get the nested value.
In your case that would look like:

test = data["profiles"]["053abfb0fb7451c291b9149ea7df88c8"]["name"]
Answered By: tiger
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.