querystring to json & json to querystring
- import
index.js
index.js
export globalqs
object with two methodsparse
andstringify
<script src="./lib/index.js"></script>
- example
//parse
let str="a=1&a=2&b=2&c=3&d=123&e=true"
let obj=qs.parse(str); //{ a: [ '1', '2' ], b: '2', c: '3',d:123,e:true }
//stringify
let obj={ a: [ '1', '2' ], b: '2', c: '3',d:123,e:true };
let str=qs.stringify(obj); //"a=1&a=2&b=2&c=3&d=123&e=true"
- install
npm i querystring2json
- example
const qs =require("querystring2json");
let str="a=1&a=2&b=2&c=3&d=123&e=true";
let obj=qs.parse(str);
console.log(obj); //{ a: [ '1', '2' ], b: '2', c: '3',d:123,e:true }
console.log(qs.stringify(obj)); //"a=1&a=2&b=2&c=3&d=123&e=true"
- install
npm install
- test
npm run test
- build
npm run build