תודה לכל המסייעים, למעשה תיקנתי את הסקריפט, והוא עובד:
import json
def process_data(data, heTitle, heShortDesc):
if isinstance(data, dict):
if data.get("heTitle") == heTitle:
heShortDesc.append(data.get("heShortDesc"))
else:
for i in data:
process_data(i, heTitle, heShortDesc)
process_data(data.get(i), heTitle, heShortDesc)
elif isinstance(data, list):
for list_item in data:
process_data(list_item, heTitle, heShortDesc)
return heShortDesc
json_file = "table_of_contents.json"
heTitle = input()
with open(json_file, 'r', encoding='utf-8') as file:
json_data = json.load(file)
a = process_data(json_data, heTitle, heShortDesc=[])
print(a)