title: How to send NULL in HTTP query string?
body: <p>I'm developing an API that can accept the main three data types as values to query string parameters: <code>boolean</code>, <code>string</code> &amp; <code>numeric</code> (<code>integer</code> or <code>float</code>). By default, everything is retrieved a string (I don't think there's a way around that), but the parameters are configured with a type so that I convert them to the proper type.</p>
  
  <p>I now need to start accepting NULL as a value, for all three data types, but I'm not sure what is the best way to do so.</p>
  
  <p>Some people seem to accept no value as NULL (<code>?param</code>, without <code>=</code>), but that is no quite working for me:</p>
  
  <ol>
  <li>I'm already accepting that as <code>true</code> for booleans, although that could be changed.</li>
  <li>It is received as an empty string, which is a valid value for the <code>string</code> data type.</li>
  </ol>
  
  <p>So, here are the only two options I can see, none of which are working for me:</p>
  
  <ol>
  <li>Use a constant, like <code>"NULL"</code> or <code>"~"</code>. That works for booleans &amp; numbers, but not for strings, as that might be the desired string value.</li>
  <li>Use an empty value. Once again, that can work for booleans &amp; numbers, but not for strings, as that might be the desired string value.</li>
  </ol>
  
  <p>Seems like using a constant might be my only choice, and to avoid issues that constant can be forbidden from strings. But is that really the only viable option? I wish there were a better way. :(</p>
  
  <p><strong><em>Edit</em></strong>: I just had another idea that might work, but I'm not sure how it would be perceived. I think it definitely breaks standards, and a lot of people would most likely not like it, but would fix my issue better than any other solution so far. Basically, the idea would be to use JSON, which supports native data types. I'm not having this issue with POST requests because they're using JSON.</p>
  
  <p>So the idea would be to take JSON in the query string, basically allowing an alternative query string that would override the standard HTTP one. Something like: <code>?_json={"foo":"bar","param":null}</code> instead of <code>?foo=bar&amp;param=~</code>. Or maybe even take over the query string entirely: <code>?{"foo":"bar","param":null}</code>.</p>