Skip to content

A robust querystring parsing module for node.js, based on the YUI QueryString module.

License

Notifications You must be signed in to change notification settings

jazzychad/querystring.node.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

querystring.node.js

This node module provides robust querystring parsing and stringifying. It is based heavily on the YUI QueryString module located here.

Acknowledgements

Thanks to Isaac Schlueter for pointing me to the YUI code and allowing me to tweak it for node.js.

querystring.js

Exports the parse and stringify methods from the querystring-parse and querystring-stringify sub-modules, repsectively.

parse example

var sys = require("util");
var qs = require("./querystring");

var str = qs.parse("foo=bar&baz=qux");
sys.puts(JSON.stringify(str)); // => {"foo":"bar","baz":"qux"}

str = qs.parse("foo[bar][][bla]=baz");
sys.puts(JSON.stringify(str)); // => {"foo":{"bar":[{"bla":"baz"}]}}

stringify example

var sys = require("util");
var qs = require("./querystring");

var obj = {"foo":"bar","baz":"qux"};
sys.puts(qs.stringify(obj)); // => foo=bar&baz=qux

obj = {"foo":{"bar":[{"bla":"baz"}]}};
sys.puts(qs.stringify(obj)); // => foo%5Bbar%5D%5B%5D%5Bbla%5D=baz

querystring-parse.js

Provides a parse function which takes a string and returns a javascript object

querystring-stringify.js

Provides a stringify function which takes a javascript object and returns a query string

Other

See test.js for a few more examples.

About

A robust querystring parsing module for node.js, based on the YUI QueryString module.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •