From c905666591ca3c58c0fda1686008ab008163147f Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 26 Feb 2024 18:04:34 +0300 Subject: [PATCH] json-as-dict --- services/db.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/db.py b/services/db.py index 6642b596..45cc005a 100644 --- a/services/db.py +++ b/services/db.py @@ -1,3 +1,4 @@ +import json import math import time @@ -52,8 +53,8 @@ class Base(declarative_base()): for c in column_names: value = getattr(self, c) if isinstance(value, JSON): - # Cast JSON column to string - data[c] = str(value) + # save JSON column as dict + data[c] = json.loads(str(value)) else: data[c] = value return data