I have JSON like string which looks like:
{key1:my.value1,key2:value2}
It could not have any nested object or arrays. I can even prove it will be always like this with regex
var re = /^\{[A-Z0-9._]+:[A-Z0-9._]+(,[A-Z0-9._]+:[A-Z0-9._]+)*\}$/i;
console.log( re.test('{key1:my.value1,key2:value2}') ) // true
It looks really similar but it's not valid JSON so I can not iterate over it.
Question: Is there a way how to make from this JSON like string valid JSON?
I was thinking about some regex or something but really not sure how to make it. Any advise?
Result: From json above my valid JSON should looks like:
{
"key1": "my.value1",
"key2": "value2"
}
my,my.value1andvalue2are all defined in the current scope?