Convert single quotes string in JSON

  eval, json, python

I have a requirement where I have to convert a single-quoted JSON string to a JSON object as follows.

a = '{'description': 'dummy_description'}'
b = eval(a)
print(f"b = {b}")
print(f"description -> {b['description']}")

Here above is achievable using an eval statement but using eval will cause code injection issues.

Is there any other way to achieve the above without using eval?

Source: Python Questions

LEAVE A COMMENT