I have string which is in form of JSON but not a valid JSON string. String is like as below (Its single line string but I have added new lines for clarity.)
"{
clientId :\"abc\",
note:\"ATTN:Please take care of item x\"
}"
I am trying to fix it (reformating to valid JSON) using javascript regular expression. I am currently using following regular expression but its not working for second property i.e. note as it has colon (:) in its value.
retObject.replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2": ');
What I am trying to do here is using regular expression to reformat above string to
"{
"clientId" :"abc",
"note":"ATTN:Please take care of item x"
}"
Tried many ways but couldnt get it just right as I am still beginer in RegEx.