How to escape double quotes in JSON using Java -
what best way handle double quotes exist inside json string ? string external source. escaping double quotes escape double quotes, ones wrap around key , value. ideally want way escape quotes inside value. in example below, string "quotes" breaks json. best way handle ? appreciate input. thanks!
@test public void isvalidjson() { string testjsonstring = "{\"messagetype\":\"typea\", \"subject\":\"here subject \"quotes\" in it\" }"; try { new jsonobject(testjsonstring); } catch (jsonexception e) { e.printstacktrace(); } }
the error is:
org.json.jsonexception: expected ',' or '}' @ 60 [character 61 line 1]
Comments
Post a Comment