0

i need to convert some data into JSON, an example is this:

{metadata:{schemaDefinitionVersion:1.},attributes:{PreferenceFrequencies:[{p:{t:"c",v:{t:"2022-10-25T16:03:19.725Z",o:"test"}},v:{t:"m",v:{response:{t:"s",v:"often"},category:{t:"s",v:"premium"}}}}]}}

i want to wrap double quotes around all the values, how do i do that efficiently?

Desired result:

[{"metadata":{"schemaDefinitionVersion":"1."},"attributes":{"PreferenceFrequencies":[{"p":{"t":"c","v":{"t":"2022-10-25T16:03:19.725Z","o":"test"}},"v":{"t":"m","v":{"response":{"t":"s","v":"often"},"category":{"t":"s","v":"premium"}}}}]}}]

Preferably i want to do this in Redshift but if it's not easy then Python will work as well. Thank you!

InSync
  • 4,851
  • 4
  • 8
  • 30
Dan Pham
  • 107
  • 6
  • 2
    Your data seems to be JSON notated using JS unquoted property name syntax. If that's the case, [convert it](https://stackoverflow.com/q/24027589) to a dictionary, then use `json.dumps()` to stringify it. – InSync Mar 31 '23 at 19:39

0 Answers0