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

jsurl-moment

v0.1.4

Published

URL friendly JSON-like formatting and parsing

Downloads

16

Readme

JSURL

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:

  • Compact: its output is much more compact than JSON + URL encoding (except in pathological cases). It is even often slightly more compact than regular JSON!
  • Readable: its output is much more readable than JSON + URL encoding.
  • Foolproof: its output only contains characters that are unaffected by URL encoding/decoding. There is no risk of missing a URL encoding/decoding pass, or of messing up a JSURL string by applying an extra URL encoding or decoding pass.
  • Easy to generate and parse

Syntax

Think of it as JSON with the following changes:

  • Curly braces ({ and }) replaced by parentheses (( and ))
  • Square brackets ([ and ]) replaced by (~ and )
  • Property names unquoted (but escaped -- see below).
  • String values prefixed by a single quote (') and escaped
  • moment values prefixed by star ('*')
  • All other JSON punctuation (colon : and comma ,) replaced by tildes (~)
  • An extra tilde (~) at the very beginning.

Property names and string values are escaped as follows:

  • Letters, digits, underscore (_), hyphen (-) and dot (.) are preserved.
  • Dollar sign ($) is replaced by exclamation mark (!)
  • Other characters with UNICODE value <= 0xff are encoded as *XX
  • Characters with UNICODE value > 0xff are encoded as **XXXX

Examples

JSON:

{"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%7D

JSURL:

~(name~'John*20Doe~age~42~children~(~'Mary~'Bill))

API

var JSURL = require("jsurl");

str = JSURL.stringify(obj);
obj = JSURL.parse(str);

Installation

The easiest way to install jsurl is with NPM:

npm install jsurl

License

This work is licensed under the MIT license.