Skip to content

Commit 0f1e15b

Browse files
author
Joel Collins
committed
Support UserString in LabThingsJSONEncoder
1 parent 574c932 commit 0f1e15b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/labthings/json/encoder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Flask JSON encoder so we get UUID, datetime etc support
22
from flask.json import JSONEncoder
33
from base64 import b64encode
4+
from collections import UserString
45
import json
56

67

@@ -20,6 +21,8 @@ def default(self, o):
2021
return o.decode()
2122
except UnicodeDecodeError: # Otherwise, base64
2223
return b64encode(o).decode()
24+
if isinstance(o, UserString):
25+
return str(o)
2326
return JSONEncoder.default(self, o)
2427

2528

0 commit comments

Comments
 (0)