From 54326f707bc59b84444a6472d31e8dbf07269eb6 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 3 May 2021 17:58:57 +0300 Subject: [PATCH] Add JSON flags support to APICall --- apiserver/service_repo/apicall.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apiserver/service_repo/apicall.py b/apiserver/service_repo/apicall.py index e1401e8..426c0d8 100644 --- a/apiserver/service_repo/apicall.py +++ b/apiserver/service_repo/apicall.py @@ -387,6 +387,7 @@ class APICall(DataContainer): self._requires_authorization = True self._host = host self._auth_cookie = auth_cookie + self._json_flags = {} @property def id(self): @@ -579,6 +580,10 @@ class APICall(DataContainer): def auth_cookie(self): return self._auth_cookie + @property + def json_flags(self): + return self._json_flags + def mark_end(self): self._end_ts = time.time() self._duration = int((self._end_ts - self._start_ts) * 1000) @@ -629,7 +634,7 @@ class APICall(DataContainer): } if self.content_type.lower() == JSON_CONTENT_TYPE: try: - res = json.dumps(res) + res = json.dumps(res, **(self._json_flags or {})) except Exception as ex: # JSON serialization may fail, probably problem with data or error_data so pop it and try again if not (self.result.data or self.result.error_data):