0.1.12 • Published 8 years ago

urlquery-to-object v0.1.12

Weekly downloads
5
License
MIT
Repository
github
Last release
8 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

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago