I need to parse data from a string as JSON. It is currently formatted as
data = "{ topic: { name: "foo", other: "bar" }}"
I am using the below regex to add quotes to the keys. This works correctly.
data_formatted = (re.sub(r"(\w+):", r'"\1":', data_raw))
My issue is that sometimes the value contains a semicolon, such as
data = "{ topic: { name: "foo", other: "bar:2" }}"
Is there away for me to target just the keys when adding quotes and leave the values as is ? (I have no access to the incoming data unfortunately)