A powerful querystring parser to use with multidimensional arrays and objects
Install the module with: npm install superqs
var qs = require('superqs');
qs.stringify({
name: 'Christopher',
born_at: new Date(),
metadata: {
username: 'chrisenytc'
}
}); // "name=Christopher&born_at=2015-12-23T20:25:25.782Z&metadata[username]=chrisenytc"
- Supports multi dimensional arrays and objects
- Converts values into their correct data types.
- Supports all data types:
strings
,integers
,booleans
,arrays
&objects
.
How to use this method
let qs = require('superqs');
// parse
qs.parse('string=value&date=2015-12-23T23:42:09.248Z&yes=true&no=false&array=1&array=2&object[a]=hello&object[b]=world&object[c][a]=3&object[c][a]=4')
// becomes ->
{
string: 'value',
date: Wed Dec 23 2015 21:42:09 GMT-0200 (BRST),
yes: true,
no: false,
array: [1,2],
object: {
a: 'hello',
b: 'world',
c: {
a: [3,4]
}
}
}
How to use this method
let qs = require('superqs');
// stringify
let result = qs.stringify({
string: 'value',
date: new Date(),
yes: true,
no: false,
array: [1,2],
object: {
a: 'hello',
b: 'world',
c: {
a: [3,4]
}
}
});
console.log(result)
// --> string=value&date=2015-12-23T23:42:09.248Z&yes=true&no=false&array=1&array=2&object[a]=hello&object[b]=world&object[c][a]=3&object[c][a]=4
Bug reports and pull requests are welcome on GitHub at https://github.com/chrisenytc/superqs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
- Fork it chrisenytc/superqs
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am "Add some feature"
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
If you have any problem or suggestion please open an issue here.
This is a fork of the project diet-qs. Give some respect to him.
Check here.