I use an old legacy framework that connects to a non-relational DB that can only receive a JSON string like this:
'{
"id":'123',
"name":'myZoo',
"ticketPrice":66.5,
"animals":['lion','zebra','wolf']
}'
I have this JSON string:
'{
"id":"123",
"name":"myZoo",
"ticketPrice":66.5,
"animals":["lion","zebra","wolf"]
}'
Using regex, I want to replace double quotes " with single quotes ' of the JSON values only ( the keys must have double quotes ).
the reason I want to use regex is because my framework cant handle JSON so I need to use it as string.
For a JSON without arrays I have this code:
/(?<=:)"((?:\\.|[^\\])*?)"/g
But, I cant make it work with arrays.