This package has been deprecated

Author message:

Use deparam.js instead

jquerydeparam

1.1.5 • Public • Published

JQuery deparam

JQuery deparam is a lightweight plugin that converts querystring to a JavaScript object

Installation

npm install --save jquerydeparam

Usage

ES6

import deparam from 'jquerydeparam';
deparam(...);

CommonJS

const deparam = require('jquerydeparam');
deparam(...);

Browser

deparam(...);

As JQuery plugin

import $ from 'jquery';
import 'jquerydeparam';
$.deparam(...);

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.log(deparam(query));

Result:

{
    key1: "value1",
    key2: "value2"
}

#2 Complex query

var query = "flag=true&arr[]=Hello&arr[]=World&ob[key1]=value1&ob[key2]=value2";
console.log(deparam(query));

Result:

{
    flag: true,
    arr: [
        "Hello",
        "World"
    ],
    ob: {
        key1: "value1",
        key2: "value2"
    }
}

Package Sidebar

Install

npm i jquerydeparam

Weekly Downloads

1

Version

1.1.5

License

MIT

Unpacked Size

41.5 kB

Total Files

13

Last publish

Collaborators

  • scssyworks