From 1da44d12ecf8ec871e8efa6227b36492ec14e414 Mon Sep 17 00:00:00 2001 From: Frikky Date: Tue, 5 Mar 2024 15:30:59 +0100 Subject: [PATCH] Minor fix to make JSON only return json if it's actually json --- backend/app_sdk/app_base.py | 9 +++++++++ backend/app_sdk/autocorrect_test.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index a8ec11be..c64939ce 100755 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -584,6 +584,15 @@ class AppBase: return newoutput except: pass + + # Dont return json properly unless actually json + if inputtype == "json": + try: + json.loads(newoutput) + return newoutput + except: + # Returns original if json fixing didn't work + return liquiddata return newoutput diff --git a/backend/app_sdk/autocorrect_test.py b/backend/app_sdk/autocorrect_test.py index d8c5dbbc..a7624c76 100644 --- a/backend/app_sdk/autocorrect_test.py +++ b/backend/app_sdk/autocorrect_test.py @@ -135,6 +135,15 @@ def patternfix_string(liquiddata, patterns, regex_patterns, inputtype="liquid"): except: pass + # Dont return json properly unless actually json + if inputtype == "json": + try: + json.loads(newoutput) + return newoutput + except: + # Returns original if json fixing didn't work + return liquiddata + return newoutput print("Start:\n%s" % input_data)