I have a Json-like string like this:
{cid: {ABCD[1]_TYPE, [text]: alphabets, time: 1/12/2010, author: xyz, best_chapter: 10.5}
And I need to add double quotes to every string to make it look like a real Json:
{"cid": {"ABCD[1]_TYPE", "[text]": "alphabets", "time": "1/12/2010", "author": "xyz", "best_chapter": "10.5"}}
I've already done this:
val jsonString = str.replaceAll("(\\w+/.)", "\"$1\"")
My regex fails and it escapes the Square Brackets like this:
{"cid": {"ABCD"["1"]"_TYPE", [""text""]: "alphabets", "time": "1/12/2010", "author": "xyz", "best_chapter": "10.5"}}
Any idea how to make the double quotes include that.
Instead of trying to describe everything that should be quoted, and escaping all the special characters, it might be easier to describe what should not be quoted.