Skip to content

Commit

Permalink
add bson json_util to MontyDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed Dec 6, 2024
1 parent a3d35a6 commit 3781457
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/monty/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@

try:
import bson
from bson import json_util
except ImportError:
bson = None
json_util = None

try:
import orjson
Expand Down Expand Up @@ -862,7 +864,9 @@ def decode(self, s):
:param s: string
:return: Object.
"""
if orjson is not None:
if bson is not None:
d = json_util.loads(s)
elif orjson is not None:
try:
d = orjson.loads(s)
except orjson.JSONDecodeError:
Expand Down

0 comments on commit 3781457

Please sign in to comment.