Skip to content

Instantly share code, notes, and snippets.

@QuynhVir
Last active December 8, 2019 06:13
Show Gist options
  • Save QuynhVir/c6db0935a9fe88d6fd66519597bfc80b to your computer and use it in GitHub Desktop.
Save QuynhVir/c6db0935a9fe88d6fd66519597bfc80b to your computer and use it in GitHub Desktop.
Remove object '$numberInt' from MongoDB BSON
def remove_numberInt(d):
for k, v in d.items():
if k == '$numberInt':
d = int(v)
if isinstance(v, dict):
d[k] = remove_numberInt(v)
if isinstance(v, list):
for i, item in enumerate(v):
if isinstance(item, dict):
d[k][i] = remove_numberInt(item)
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment