npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jsonurl/jsonurl

v1.1.8

Published

JSON->URL defines a text format for the JSON data model suitable for use within a URL/URI (as described by RFC3986).

Downloads

30,028

Readme

JSON→URL

License: MIT NPM version CI Quality Gate Coverage Lines of Code Security Rating Vulnerabilities Maintainability Rating Known Vulnerabilities FOSSA Status Contributor Covenant Conventional Commits project chat

About

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.

Usage

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

npm install @jsonurl/jsonurl --save

CJS

const JsonURL = require("@jsonurl/jsonurl");

ES6 (Node + Babel)

import JsonURL from "@jsonurl/jsonurl";

Browser script tag

<script
    src="https://cdn.jsdelivr.net/npm/@jsonurl/[email protected]"
    integrity="sha512-LIJoXzT8Z9ZYDVCop/RciWbhJCDBzOevskMv9YPLHI8kGUtJ32DHHDWdIBLBmMoKkMr7vsZEysOrOBbVg7yioA=="
    crossorigin="anonymous"></script>

The JavaScript API

Once included, the API is the same for all three.

RunKit: Hello, World!

let value = JsonURL.parse( "(Hello:World!)" );
let string = JsonURL.stringify( value );

If you intend to use JSON→URL inside a browser's address bar then you'll want to enable the AQF (address bar query string friendly) syntax.

RunKit: Hello, Browser Address Bar!

let value = JsonURL.parse( "(Hello:Address Bar!!)",  { AQF: true });
let string = JsonURL.stringify( value,  { AQF: true } );

Options - noEmptyComposite

The JSON→URL specification defines the empty composite value, (), because an empty array is indistinguishable from an empty object. This works well in practice, generally, but it can lead to counterintuitive results when parsing JSON→URL text into a language-native object and then stringifying it back into JSON→URL text; the input text doesn't "round-trip" back to itself as expected.

The noEmptyComposite parse option causes the character sequence () to be parsed as an empty array, and the character sequence (:) to be parsed as an empty object. And the noEmptyComposite stringify option instructs stringify to generate those strings appropriately.

RunKit: noEmptyComposite

let value = JsonURL.parse( "(Array:(true,false,(nested),()),Object:(nested:(:)))",  { AQF: true, noEmptyComposite: true });
let string = JsonURL.stringify( value,  { AQF: true, noEmptyComposite: true });

Options - More

There are additional options available. The typescript definition file is a good place to learn more.

JSON→URL has no runtime dependencies.

Security

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 reasonable limit values are set by default.

License

FOSSA Status