query-string-lite
v0.2.2
Published
lightweight query string encoder/decoder
Downloads
3
Maintainers
Readme
query-string-lite
install
npm install query-string-lite
usage
import {
decode,
encode
} from "query-string-lite";
const querystring = "?string=question&boolean&string=&string=42"
const query = decode(querystring);
console.log(JSON.stringify(query))
//=> '{ boolean: true, string: [ "question", "", "42" ]}'
console.log(encode(query))
//=> '?boolean&string=question&string=&string=42'
non-ascii
same thing, different characters…
const querystringZH = "?聪明&名字=Fernando&名字=&名字=王"
const queryZH = decode(querystring);
console.log(JSON.stringify(query))
//=> '{ 名字: [ "Fernando", "", "王" ], 聪明: true }'
console.log(encode(query))
//=> '?名字=Fernando&名字=&名字=王&聪明'
licence
MIT Copyright (c) 2020 Fernando G. Vilar.