From c4fd9aa793d582c03e7b289f4949412674a19a96 Mon Sep 17 00:00:00 2001 From: nineven Date: Fri, 11 Feb 2022 04:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djson=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/sysconfig.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fir_ser/api/utils/sysconfig.py b/fir_ser/api/utils/sysconfig.py index 76b6a80..2db216f 100644 --- a/fir_ser/api/utils/sysconfig.py +++ b/fir_ser/api/utils/sysconfig.py @@ -33,7 +33,14 @@ class ConfigCacheBase(object): def get_value_from_db(self, key): sys_obj = SystemConfig.objects.filter(key=key).first() - return SystemConfigSerializer(sys_obj).data + data = SystemConfigSerializer(sys_obj).data + value = data.get('value', '') + if value: + try: + data['value'] = json.loads(value) + except Exception as e: + logger.warning(f"db config - json loads failed {e}") + return data def get_value(self, key, data=None): if data is None: