java - Using regex to remove JSON quotes -
java - Using regex to remove JSON quotes -
i beingness given json external process can't change, , need modify json string downstream java process work. json string looks like:
{"widgets":"blah","is_dog":"1"}
but needs like:
{"widgets":blah,"is_dog":"1"}
i have remove quotes around blah
. in reality, blah
huge json object, , i've simplified sake of question. figured i'd attack problem doing 2 string#replace
calls, 1 before blah
, , 1 after it:
datastring = datastring.replaceall("{\"widgets\":\"", "{\"widgets\":"); datastring = datastring.replaceall("\",\"is_dog\":\"1\"}", ",\"is_dog\":\"1\"}");
when run vague runtime error:
illegal repetition
can regex maestros spot i'm going awrye? in advance.
i believe need escape braces. braces used repetition ((foo){3}
looks foo 3 times in row); hence error.
note: in case needs double escaping: \\{
.
java regex
Comments
Post a Comment