title: Parse escaped JSON in PHP
body: <p>I'm a newb in PHP world and I've problems parsing JSON in PHP. I want to POST data to PHP script with my Java client using <code>Apache HttpClient 4.x</code> and <code>Gson</code>.</p>
  
  <p>My JSON:</p>
  
  <pre><code>[{"Knt_KntWatchId":"15","type":"INSERT","Knt_Nazwa1":"a"},{...},...]
  </code></pre>
  
  <p>I'm sending it with Java using <code>HttpClient</code> and <code>Gson</code>:</p>
  
  <pre><code>    List&lt;Contact&gt; contacts = ...;
      HttpPost post = new HttpPost(CONTACTS_SERVICE);
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
      nameValuePairs.add(new BasicNameValuePair("key", AppConstants.KEY));
      nameValuePairs.add(new BasicNameValuePair("data", new Gson().toJson(contacts)));
      post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      post.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  </code></pre>
  
  <p>On page:</p>
  
  <pre><code>if (isset($_POST['data'])) {
      $data = $_POST['data'];
      $json = json_decode($data, true);
      var_dump($json);
      var_dump($data);
  </code></pre>
  
  <p>What I'm getting is:</p>
  
  <pre><code>NULL string(3651) "[{\"Knt_KntWatchId\":\"15\",\"type\":\"INSERT\",\"Knt_Nazwa1\":\"a\"},...
  </code></pre>
  
  <p>How can I get it working?</p>
  
  <p>PHP 5.2 - can't use <code>json_last_error()</code></p>