I have a stringified JSON object that I want to pass into my WebView as a string. If my JSON string is a simple one-level JSON like this:
JSONObject object = new JSONObject;
object.put("key1", "val1");
object.put("key2", "val2");
String myValue = object.toString();
And I run evaluateJavascript like this:
webView.evaluateJavascript("console.log('" + myValue + "')", null)
Then the console log I get is this:
{"key1": "val1", "key2", "val2"}
Which is correct.
But if my JSON has a sub JSON inside it, then the stringified version of that JSON should have escaped quotes in it for that inner JSON. So if I did this:
JSONObject object = new JSONObject();
object.put("key1", "val1");