title: Android Volley POST - JSON Encoding in body
body: <p>I'm using Volley Android for POST some data to a Restful Api endpoint, using postman it works great body data in <code>raw</code> and <code>application/json</code> e.g:</p>
  
  <pre><code>{
      "operation": "someaction",
      "key": "pk_test_fssdfsdfjkhkjsdhf84334",
      "token": "tk_test_432332sdxxaJJJJHHHshhsas",
      "ssids":[[{
          "mac":"34:15:13:d4:59:f1" //&lt;--this is important here, it's mac addr
              }]] //&lt;-- yup, with double double [[ ... ]]
  }
  </code></pre>
  
  <p>It works using POSTMAN and returns
  <a href="https://i.stack.imgur.com/kvfXj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kvfXj.png" alt="enter image description here"></a></p>
  
  <p>The issue starts when I use volley in the code below:</p>
  
  <pre><code>public void getBleeCardData(Response.Listener&lt;String&gt; response, final String ssidsdata, final ProgressDialog pd)throws JSONException {
  
      String url = "https://www......com/api/something.do";
  
      JSONObject jsonBody = new JSONObject();
                 jsonBody.put("operation", "something");
                 jsonBody.put("key", "pk_try_oqiwFHFKjkj4XMrh");
                 jsonBody.put("token", "tk_tkn_erwweelWgH4olfk2");
                 jsonBody.put("ssids", ssidsdata.toLowerCase()); 
  
      final String mRequestBody = jsonBody.toString();
  
      RequestQueue queue = Volley.newRequestQueue(context);
      StringRequest postRequest = new StringRequest(Request.Method.POST, url,new Response.Listener&lt;String&gt;() {
  
                  @Override
                  public void onResponse(String response) {
                      Log.d("Response", response);
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      Log.d("ERROR", "error =&gt; " + error.toString());
                  }
              }
      ) {
          @Override
          public byte[] getBody() throws AuthFailureError {
              try {
                  return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
              } catch (UnsupportedEncodingException uee) {
                  VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
                  return null;
              }
          }
  
          @Override
          public String getBodyContentType() {
              return "application/x-www-form-urlencoded; charset=UTF-8";
          }
      };
      queue.add(postRequest.setRetryPolicy(new DefaultRetryPolicy(30000,
              DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
              DefaultRetryPolicy.DEFAULT_BACKOFF_MULT))); }
  </code></pre>
  
  <p>I need help with the encoding, using Volley the data sent like:</p>
  
  <p>{"operation":"dataMachines","key":"pk_test_6pRNAHGGoqiwFHFKjkj4XMrh","token":"tk_test_ZQokik736473jklWgH4olfk2","ssids":"[[{\"mac\":\"34:15:13:d4:59:f1\"}]]"}</p>
  
  <p>Why is sending this node like <code>"ssids":"[[{\"mac\":\"34:15:13:d4:59:f1\"}]]"}</code>like this?, What about the <code>"\"</code>, some special encoding to remove it?</p>
  
  <p>Is possible change the encoding to prevent those <code>"\"</code>?</p>