package
URL friendly JSON-like formatting and parsing
npm install jsurlGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
JSURL is an alternative to JSON + URL encoding (or JSON + base64 encoding). It makes it handy to pass complex values via URL query parameters.
JSURL has been designed to be:
Think of it as JSON with the following changes:
{ and }) replaced by parentheses (( and ))[ and ]) replaced by (~ and )') and escaped: and comma ,) replaced by tildes (~)~) at the very beginning.Property names and string values are escaped as follows:
_), hyphen (-) and dot (.) are preserved.$) is replaced by exclamation mark (!)0xff are encoded as *XX0xff are encoded as **XXXXJSON:
{"name":"John Doe","age":42,"children":["Mary","Bill"]}JSON + URL encoding:
%7B%22name%22%3A%22John%20Doe%22%2C%22age%22%3A42%2C%22children%22%3A%5B%22Mary%22%2C%22Bill%22%5D%7DJSURL:
~(name~'John*20Doe~age~42~children~(~'Mary~'Bill))var JSURL = require("jsurl");
str = JSURL.stringify(obj);
obj = JSURL.parse(str);
// return def instead of throwing on error
obj = JSURL.tryParse(str[, def]);The easiest way to install jsurl is with NPM:
npm install jsurlThis work is licensed under the MIT license.