Skip to content

Commit

Permalink
json: conditionaly use orjson or json
Browse files Browse the repository at this point in the history
  • Loading branch information
MainRo committed Sep 21, 2023
1 parent 5f7cda2 commit cad0e67
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rxsci/container/json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import typing
import orjson as json

serialization_as_string = True
try:
import orjson as json
serialization_as_string = False
except Exception:
import json
import rx
import rx.operators as ops
import rxsci.io.file as file
Expand Down Expand Up @@ -90,7 +94,9 @@ def _dump(source):
def on_subscribe(observer, scheduler):

def on_next(i):
line = json.dumps(i).decode()
line = json.dumps(i)
if serialization_as_string is False:
line = line.decode()
line += newline
observer.on_next(line)

Expand Down

0 comments on commit cad0e67

Please sign in to comment.