From ec1b84e7881977d7ec1fec7ecf00b45770f5d832 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Thu, 9 Jun 2022 09:27:47 +1000 Subject: [PATCH] fix: adding loopjson encoder --- LoopStructural/utils/json_encoder.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 LoopStructural/utils/json_encoder.py diff --git a/LoopStructural/utils/json_encoder.py b/LoopStructural/utils/json_encoder.py new file mode 100644 index 000000000..e6ce90cad --- /dev/null +++ b/LoopStructural/utils/json_encoder.py @@ -0,0 +1,17 @@ +import json +class LoopJSONEncoder(json.JSONEncoder): + def default(self, obj): + """All jsonable loop objects should have a tojson method + + Parameters + ---------- + obj : LoopStructuralObject + An object from loopstructural + + Returns + ------- + str + string representing the json encoding + """ + return obj.__tojson__() + \ No newline at end of file