import json from pprint import pprint tokens = set() with open("tests/test.json", "r") as txt: tests : dict = json.loads(txt.read()) for test_name, test_value in tests["basic_unit_tests"].items(): for token in test_value["parsed"]: tokens.add(list(token.keys())[0]) pprint(tokens)