import json filePath = 'test.json' with open(filePath, 'r', encoding='utf-8') as f: data = json.load(f) print(data) posts = data['data']['xdt_api__v1__feed__user_timeline_graphql_connection']['edges'] posts = [post['node'] for post in posts] for post in posts: biggestRes = 0 images = post['image_versions2']['candidates'] for image in images: width = image['width'] height = image['height'] if width * height > biggestRes: biggestRes = width * height goodPost = post print(goodPost)