title: How to format JSON string of data to send from WebView to JavaScript?
body: <p>I want to pass multiple values from Android WebView to JavaScript.
  The Problem is, that the String i receive in JS is absolutely raw (like control characters showing in plain text).</p>
  
  <p>So my specific problem is that i send the following String from Java:</p>
  
  <pre><code>final String chartData = "{ \"data\": 1000, a: 10, b: 30, c: [ 5, 10, 15 ] }";
  </code></pre>
  
  <p>And what i receive is absolutely raw:</p>
  
  <pre><code>"{ \"data\": 1000, a: 10, b: 30, c: [ 5, 10, 15 ] }"
  </code></pre>
  
  <p>But i want this (the java-parsed string):</p>
  
  <pre><code>{ "data": 1000, a: 10, b: 30, c: [ 5, 10, 15 ] }
  </code></pre>
  
  <p>I dont handle any JSON now, so you can ignore the "syntaxproblem" in the JSON string. I just want to receive the String correctly first. Here is my code so far:</p>
  
  <p>WebViewActivity.java</p>
  
  <pre><code>webView = (WebView) findViewById(R.id.webView1);
  
      webView.getSettings().setJavaScriptEnabled(true);
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webSettings.setAllowUniversalAccessFromFileURLs(true);
      webSettings.setAllowFileAccessFromFileURLs(true);
  
      final String chartData = "{ \"data\": 1000, a: 10, b: 30, c: [ 5, 10, 15 ] }";
  
      webView.setWebChromeClient(new WebChromeClient());
      webView.setWebViewClient(new WebViewClient(){
          public void onPageFinished(WebView view, String url){
              webView.loadUrl("javascript:showAlert('message from android')");
              webView.loadUrl("javascript:createChart('"+chartData+"')");
          }
      });
  
      webView.loadUrl("file:///android_asset/report.html");
  </code></pre>
  
  <p>report.html</p>
  
  <pre><code>&lt;div id="debugContainer"&gt;
      debug
  &lt;/div&gt;
  </code></pre>
  
  <p>script.js</p>
  
  <pre><code>function createChart(lineChartData){
  document.getElementById('debugContainer').innerHTML = JSON.stringify(lineChartData, null, 4);}
  </code></pre>