querystring to json & json to querystring
- import
index.js
index.js
export global qs
object with two methods parse
and stringify
<script src="./lib/index.js"></script>
//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"
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"