[utils] js_to_json: Fix bug in f55523c (#5771)

Authored by: ChillingPepper, pukkandan
This commit is contained in:
ChillingPepper
2022-12-30 07:38:38 +01:00
committed by GitHub
parent fe74d5b592
commit d5f043d127
2 changed files with 86 additions and 1 deletions

View File

@@ -3360,7 +3360,13 @@ def js_to_json(code, vars={}, *, strict=False):
return f'"{i}":' if v.endswith(':') else str(i)
if v in vars:
return json.dumps(vars[v])
try:
if not strict:
json.loads(vars[v])
except json.decoder.JSONDecodeError:
return json.dumps(vars[v])
else:
return vars[v]
if not strict:
return f'"{v}"'