im catching program packets and i got this bson: GwAAAAJJRAADAAAAU1QAElQAseX LO 2QgAEG1jAAEAAAAA
Also i found a site to convert it to json, but its on java script, how to make similar using python?
site: http://mcraiha.github.io/tools/BSONhexToJSON/bsonbase64tojson.html
code:
import base64
import bsonjs
b64String = base64.b64encode(data)
packet = b64String[16:]
print(packet)
CodePudding user response:
This is can solve your need
import bsonjs
import base64
yourString = "GwAAAAJJRAADAAAAU1QAElQAseX LO 2QgAEG1jAAEAAAAA"
outJSON = bsonjs.dumps(base64.b64decode(yourString))
print(outJSON)
output Dict
:
{ "ID" : "ST", "T" : 637750756710999473 }
Let me know if you have any issues please