A library for use JSON.stringify and JSON.parse based on loops and encode, decode query strings
npm install simple-parseA small library for JSON parse/stringify methods based on loops and encode, decode query strings.
js
const simpleParse = require("simple-parse");
const string = simpleParse.stringify({ key1: "value1", key2: "value2" }); // '{"key1":"value1","key2":"value2"}'
const json = simpleParse.parse('{"key1":"value1","key2":"value2"}'); // { key1: 'value1', key2: 'value2' }
`
$3
queryParse take a query string and convert it to object.
Query string can have any prefix, it just cut off.
Key without values set to empty string.
queryStringify take a object and convert it in query string, it is also can
take any prefix, but by default we return the query string without a prefix.
`js
const simpleParse = require("simple-parse");
const json = simpleParse.queryParse('key=value&value1=key1'); // { key: 'value', value1: 'key1' }
const json = simpleParse.queryParse('?key=value'); // { key: 'value' }
const json = simpleParse.queryParse('key&value=key1'); // { key: '', value: 'key1' }
const string = simpleParse.queryStringify({ key: 'value' }); // 'key=value'
const string = simpleParse.queryStringify({ key: 'value' }, '#'); // '#key=value'
const string = simpleParse.queryStringify({ key: '' }, '&'); // '&key=value'
``