title: Java sends a JSON string in POST request with escaped double quotes
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6715650/how-can-i-stop-http-from-escaping-quotes">How can I stop HTTP from escaping quotes?</a>  </p>
  </blockquote>
  
  
  
  <p>I am creating a JSONObject and sending JSON string to a server in a POST request body.</p>
  
  <pre class="lang-java prettyprint-override"><code>public String toJson() {
      JSONObject filter = new JSONObject();
      try {
          filter.put("gender", gender.getCode());
          filter.put("feature_id", productCategory);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      JSONObject filterObject = new JSONObject();
      try {
          filterObject.put("filter", filter);
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      return filterObject.toString();
  }
  </code></pre>
  
  <p>So I'm creating a request:</p>
  
  <pre><code>private IJsonExecutorInterface requestExecutorForRelativePathAndParams(String path, WebParams params) throws UnsupportedEncodingException {
      HttpPost postRequest = new HttpPost(rootUrl + path);
  
      if(params != null) {
          postRequest.setHeader("content-type", params.getContentType());
          postRequest.setEntity(params.getFormEntity());
      }
  
      // Blah blah
  
      return executor;
  }
  
  public IJsonExecutorInterface getProducts(ProductFilter filter, int offset, int limit) throws UnsupportedEncodingException {
      WebParams webParams = new WebParams();
      webParams.addPair("filter", filter.toJson());
      webParams.addPair("offset", String.format("%d", offset));
      webParams.addPair("limit", String.format("%d", limit));
      return requestExecutorForRelativePathAndParams("products", webParams);
  }
  
  // WebParams class
  
  
  public class WebParams {
      private ArrayList&lt;NameValuePair&gt; params;
      private String contentType = "application/x-www-form-urlencoded";
  
      public WebParams() {
          params = new ArrayList&lt;NameValuePair&gt;();
      }
  
      public void addPair(String name, String value) {
          params.add(new BasicNameValuePair(name, value));
      }
  
      public String getContentType() {
          return contentType;
      }
  
      public HttpEntity getFormEntity() throws UnsupportedEncodingException {
          return new UrlEncodedFormEntity(params);
      }
  }
  </code></pre>
  
  <p>I see it in debugger: it's ok.</p>
  
  <p>But on my server I getting something like this:</p>
  
  <pre><code>Array
  (
      [filter] =&gt; {\"gender\":\"w\",\"feature_id\":\"41_7459\"}
      [offset] =&gt; 0
      [limit] =&gt; 18
  )
  </code></pre>
  
  <p>The quotes ARE escaped.</p>
  
  <p>I don't want to replace something on the server. <code>replace("\\\"", "\"")</code> in Java doesn't affect on the string.</p>