RFC8259 describes the JSON data model and interchange format, which is widely used in application-level protocols including RESTful APIs. It is common for applications to request resources via the HTTP POST method, with JSON entities. However, POST is suboptimal for requests which do not modify a resource's state. JSON→URL defines a text format for the JSON data model suitable for use within a URL/URI.
JSON→URL is available as a commonjs module (suitable for use in Node), ES6 module, or a script that may be used directly in a browser.
npm install @jsonurl/jsonurl --save
const JsonURL = require("@jsonurl/jsonurl");
ES6 (Node + Babel)
import JsonURL from "@jsonurl/jsonurl";
Browser script tag
<script src="https://cdn.jsdelivr.net/npm/@firstname.lastname@example.org" integrity="sha384-X9eggnze0lccwuooEyVZu+LN9+HDcchxa9L9K1NObZelfMNcGSzT822Ikr2eZ3WD" crossorigin="anonymous"></script>
Once included, the API is the same for all three.
let p = new JsonURL(); let value = p.parse( "(Hello:World!)" );
There are options available, but that's all you need to get started.
JSON→URL has no runtime dependencies.
The parser is designed to parse untrusted input. It supports limits on the number of parsed values and depth of nested arrays or objects. When the limit is exceeded an Error is thrown, and sane limit values are set by default.