use json to make the output a bit nicer

This commit is contained in:
JJTech0130 2023-04-10 20:22:26 -04:00
parent c68d710952
commit 26e4257cac
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6

15
ids.py
View file

@ -105,4 +105,17 @@ body = response['b']
body = zlib.decompress(body, 16 + zlib.MAX_WBITS) body = zlib.decompress(body, 16 + zlib.MAX_WBITS)
body = plistlib.loads(body) body = plistlib.loads(body)
print(f"Body: {body}") # Recurse over the entire body, replacing all bytes with base64 encoded strings
def recurse(obj):
if isinstance(obj, bytes):
return b64encode(obj).decode()
elif isinstance(obj, dict):
return {k: recurse(v) for k, v in obj.items()}
elif isinstance(obj, list):
return [recurse(v) for v in obj]
return obj
body = recurse(body)
import json
print(json.dumps(body, indent=4))