auchenberg/crossroads.js — comment on commit 89fb9c14931d052c25b3a6a34dfe0503709e71cf
File:  line 0
By millermedeiros:

you can manipulate the data format by using the `normalize_` option:

```js
/**
* Convert Query String into an Object
* @param {string} queryString Query String to be parsed
* @return {Object.} Object with all the query "params => values" pairs.
*/
function toQueryObject(queryString){
var queryArr = (queryString || '').replace('?', '').split('&'),
n = queryArr.length,
queryObj = {},
value;
while (n--) {
queryArr[n] = queryArr[n].split('=');
value = queryArr[n][1];
queryObj[queryArr[n][0]] = isNaN(value)? value : parseFloat(value);
}
return queryObj;
}

///just so you can reuse function to multiple routes..
function parseQueryRoute(req, vals) {
//normalize should return an Array
return [{
params : vals,
queries : (vals.query)? toQueryObject(vals.query) : null
}];
}

var queryRoute = crossroads.addRoute('/{section}:query:');
queryRoute.matched.add(console.log, console);
queryRoute.rules = {
normalize_ : parseQueryRoute
};

crossroads.parse('/foo/?lorem=ipsum&dolor=amet');
```

I created a new feature request a couple weeks ago to [allow changing the data format](https://github.com/millermedeiros/crossroads.js/issues/31).

cheers!