I am currently working on a python application, that works with facebook api's. As we all know, facebook loves their own technology and is working with zstd for data compression.
The problem: facebook is returning either a uncompressed response with normal json or if the response is longer, it is responding with a zstd compressed json.
My current code is something like this:
import zstd
import json
def handle_response(response)
json = None
try:
json = json.loads(zstd.decompress(response.content))
except:
json = json.loads(response.text)
return json
I am currently wondering, if there is a more clean way to do this and even detect zstd.