title: x-www-form-urlencoded Vs json HTTP POST
body: <p>It's hard to decide,<br>
  currently I'm sending data as x-www-form-urlencoded with php lib curl with </p>
  
  <pre><code>curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this-&gt;arguments));
  </code></pre>
  
  <p>or</p>
  
  <pre><code>curl_setopt($curl, CURLOPT_POSTFIELDS, $this-&gt;arguments);
  </code></pre>
  
  <p><em>first question:</em> second one seems to be larger content length, first solution is probably better? </p>
  
  <p>It's practical for flat messages like:</p>
  
  <pre><code>{
      "name": "John",
      "token": "2121232145",
      "code": "7",
      "data": "Hello"
  }
  </code></pre>
  
  <p>But I can have also a data field that represent a object, in this case I was enconding it, but doing that (url encoding a Json) is terribly verbose and ugly messages, </p>
  
  <p>On the other side I tried sending it as application/json content-type </p>
  
  <pre><code>curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this-&gt;arguments));
  </code></pre>
  
  <p>the content-length is larger for small messages but with embedded json, it's clearly better</p>
  
  <p>But x-www-form-urlencoded is also close to the forms data I need to send, except when a json is embedded</p>
  
  <p>It would not be elegant to have 2 differents servlet parse methods depending on the content types, so is there another option?</p>