I am trying to do the following with Python3:
data = json.dumps(packet)
s = StringIO()
g = gzip.GzipFile(fileobj=s, mode='w')
g.write(data)
g.close()
gzipped_body = s.getvalue()
But it keeps complaining with the following error:
TypeError: string argument expected, got 'bytes'
The example code I'm using is based on Python2 so I am thinking there is some changes in StringIO that might be causing this but I'm not sure. Anyone give me some hints on how to get a gzipped string of some JSON in Python3?