JQuery deparam
JQuery deparam is a lightweight plugin that converts querystring to a JavaScript object
Installation
npm install --save jquerydeparam
Usage
ES6
;;
CommonJS
const deparam = ;;
Browser
;
As JQuery plugin
;;$;
Note: JQuery deparam is dependent on jquery. Therefore, if the package throws an error, you know what to do!
How it works?
Deparam converts simple and complex query strings into JavaScript objects. Examples are shown below:
#1 Simple query
var query = "key1=value1&key2=value2";console;
Result:
key1: "value1" key2: "value2"
#2 Complex query
var query = "flag=true&arr[]=Hello&arr[]=World&ob[key1]=value1&ob[key2]=value2";console;
Result:
flag: true arr: "Hello" "World" ob: key1: "value1" key2: "value2"