- Equivalent to jQuery.param (based on jQuery 3.x)
- No dependencies
- Universal (Isomorphic)
- ES5
Node.js:
$ npm install jquery-param --save
Bower (DEPRECATED):
$ bower install jquery-param
the browser:
<script src="jquery-param.min.js"></script>
Node.js:
const param = require('jquery-param');
let obj = { key1: 'value1', key2: [10, 20, 30] };
let str = param(obj);
// => "key1=value1&key2[]=10&key2[]=20&key2[]=30"
AMD:
require(['jquery-param'], function (param) {
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
var str = param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
});
directly:
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
var str = window.param(obj); // global object
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
Chrome, Firefox, Safari, Edge, and IE9+.
MIT