Skip to content

Commit

Permalink
changing inf and nan to work with json dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
melgazar9 committed Oct 11, 2023
1 parent 46d971d commit 842a58a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tap_mongodb/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

def recursive_replace_inf_in_dict(dct):
for key, value in dct.items():
if value in [-math.inf, math.inf]:
dct[key] = str(dct[key])
if value in [-math.inf, math.inf, math.nan]:
dct[key] = None
elif isinstance(value, list):
for i, item in enumerate(value):
if isinstance(item, dict):
recursive_replace_inf_in_dict(item)
elif item in [-math.inf, math.inf]:
value[i] = str(item)
elif item in [-math.inf, math.inf, math.nan]:
value[i] = None
elif isinstance(value, dict):
recursive_replace_inf_in_dict(value)
return
Expand Down

0 comments on commit 842a58a

Please sign in to comment.