Troy Taylor

@troystaylor.com

My husband and I run a game store and after all the tariff announcements, he decided to write out kind of a "behind the scenes" of how we spend and spill it out for people who don't understand. He's had so many reactions and shares I wanted to bring it here, too.

BildBildBildBild

I've been building a Power Platform connector with large response objects (more than the 512-object allowed by Swagger). The easiest way I've found to count the number of objects (object and keys) is to use python with the snippet below. Does anyone have an easier way or a tool they use?

import json

def count_objects(data):
    count = 0
    if isinstance(data, dict):
        count += 1  # Count the current dictionary
        count += len(data)  # Count the keys in the current dictionary
        for key, value in data.items():
            count += count_objects(value)
    elif isinstance(data, list):
        for item in data:
            count += count_objects(item)
    return count

with open('swagger.json', 'r') as file:
    json_data = json.load(file)

total_objects = count_objects(json_data)

print(f'Total number of objects and keys in paths: {total_objects}')