0.1.12 • Published 9 years ago

urlquery-to-object v0.1.12

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

urlquery-to-object

Given a query string transform to a corresponding javascript object.

var queryObject = require('urlquery-to-object')
var querystring = 'one=1&two=2&three=3'
console.log(queryObject(querystring))

// {one: 1, two: 2, three: 3}

Also, transform a query object into a query string:

var queryObject = require('urlquery-to-object')
var queryobj = {one: 1, two: 2, three: 3}
console.log(queryObject.queryString(queryobj))

// 'one=1&two=2&three=3'

If needed, change or add key/value pairs:

var queryObject = require('urlquery-to-object')
var queryobj = {one: 1, two: 2, three: 3}
console.log(queryObject.queryString(queryobj, {two:'II', three:undefined, four:4}))

// 'one=1&two=II&four=4'

And convert array values:

var queryObject = require('urlquery-to-object')
var queryobj = {one: 1, two: 2, three: 3}
console.log(queryObject.queryString(queryobj, {four:[4,'eight']}))

// 'one=1&two=2&three=3&four=4&four=eight'

install

npm install urlquery-to-object

license

MIT

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago