diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2020-04-28 12:34:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-28 18:34:05 +0200 |
| commit | cb2b4e3522cb7f426ba5ad3e68deb9e6ccc581ec (patch) | |
| tree | 2a2f38823c3c9f0b5439ce2aa7c9040299109292 /lib/utils/json.py | |
| parent | eb526927e16954390d06929535d6f5c3766b5f6c (diff) | |
electron simulator (#531)
Diffstat (limited to 'lib/utils/json.py')
| -rw-r--r-- | lib/utils/json.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/utils/json.py b/lib/utils/json.py new file mode 100644 index 00000000..c670a46b --- /dev/null +++ b/lib/utils/json.py @@ -0,0 +1,15 @@ +from flask.json import JSONEncoder + + +class InkStitchJSONEncoder(JSONEncoder): + """JSON encoder class that runs __json__ on an object if available. + + The __json__ method should return a JSON-compatible representation of the + object. + """ + + def default(self, obj): + try: + return obj.__json__() + except AttributeError: + return JSONEncoder.default(self, obj) |
