I ran into this while calling Asp.net WebMethods using jQuery.ajax. The query string for these requests gets generated by the output from jQuery.param(options.data), where options is the object passed into jQuery.ajax.
Asp.net WebMethods are simply methods on a class with a [WebMethod] attribute. When the web server receives the request, it uses the path component from the url to select the class, and the path plus the query string keys to work out which method to call. The keys from the query string are matched against the argument names of the methods, so if a key is missing the web request will fail due to not being able to find the correct WebMethod. I imagine that other frameworks might use the same abstraction.
So, stripping keys with null values would be a breaking change for me.
The code I an working on previously used the ajax wrapper from the Prototype library, here's the output it produces:
- Object.toQueryString({
- "alpha":"value",
- "null":null,
- "undefined":undefined,
- "beta":"value"});
- ==>
- "alpha=value&null=&undefined&beta=value"
Null values are treated as empty string, and undefined values are sent by key only, with no "=".
This is more subtle behaviour than I suggested above, what do you think?