0.2.5 • Published 8 years ago

query-string-object v0.2.5

Weekly downloads
1,536
License
-
Repository
github
Last release
8 years ago

##querystring Build Status

support object or array like php did: ?a[]=1&a[]=2 -> a=1,2

###Usage

install in shell

npm install query-string-object

in js file

qs = require('query-string-object')
qs('xx=yy&zz..') // just like what is pass to the native qs.parse
qs.stringify({
  fInt: 1,
  fString: 'string',
  fObject: {
    anobject: {a:1, b:2},
    anything: 'thing'
  },
  fArray: [1,2,"string"]
}) 
// fInt=1&fString=string&fObject[anobject][a]=1&fObject[anobject][b]=2&fObject[anything]=thing&fArray[]=1&fArray[]=2&fArray[]=string

###Tests

npm install
./node_modules/.bin/mocha --reporter tap test.js

###Expects

####a=1&b=2

output

{
  a:1,
  b:2 
}

####a=1&b[]=1&b[]=2&c=3

output

({
  a: 1,
  b: [1, 2],
  c: 3
});

####a=1&b[]=1&c=3

output

({
  a: 1,
  b: [1],
  c: 3
});

####a=1&b1=1&c3=2&c=3

output

({
  a: 1,
  b: {
    1: 1
  },
  c: {
    3: 2
  }
});

####a=1&beric=dum&cstive=jobs&c=3

output
({
  a: 1,
  b: {
    eric: "dum"
  },
  c: {
    stive: "jobs"
  }
});

####a=1&beric=dum&bstive=jobs&c=3

output

({
  a: 1,
  b: {
    eric: "dum",
    stive: "jobs"
  },
  c: 3
});

####a=1&beric=dum&bstive=jobs&bstive=fans&c=3

output

({
  a: 1,
  b: {
    eric: ["dum"],
    stive: ["jobs", "fans"]
  },
  c: 3
});
0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago