import json

def summarize_json(data, max_depth=2, current_depth=0, list_sample_size=1):
    if isinstance(data, dict):
        if current_depth >= max_depth:
            return f"dict with keys: {list(data.keys())[:10]}" + ("..." if len(data.keys()) > 10 else "")
        result = {}
        for k, v in data.items():
             result[k] = summarize_json(v, max_depth, current_depth + 1)
        return result
    elif isinstance(data, list):
        if len(data) == 0: return []
        if current_depth >= max_depth:
            return f"list of length {len(data)}"
        sample = [summarize_json(data[i], max_depth, current_depth + 1) for i in range(min(list_sample_size, len(data)))]
        if len(data) > list_sample_size:
             sample.append(f"... and {len(data)-list_sample_size} more items")
        return sample
    elif isinstance(data, str):
        val = data.replace('\n', ' ')
        return val[:100] + "..." if len(val) > 100 else val
    else:
        return data

for file in ["tmp_api1.json", "tmp_api2.json"]:
    print(f"\n================ {file} ================")
    try:
        with open(file, "r") as f:
            js = json.load(f)
            print(json.dumps(summarize_json(js, max_depth=4), indent=2, ensure_ascii=False))
    except Exception as e:
        print(f"Error: {e}")
