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

rjson

v0.2.4

Published

RJSON (Recursive JSON) converts any JSON data collection into more compact recursive form.

Downloads

155

Readme

RJSON: compress JSON to JSON

RJSON (Recursive JSON) converts any JSON data collection into more compact recursive form. Compressed data is still JSON and can be parsed with JSON.parse. RJSON can compress not only homogeneous collections, but any data sets with free structure.

RJSON is single-pass stream compressor, it extracts data schemes from document, assign each schema unique number and use this number instead of repeating same property names again and again. Each data schema is unique set of keys ordered with natural sort (alphabetically). After packing and unpacking order of keys may be changed but restored document will be fully identical to the original document.

More information about RJSON data format you can find at my blog post Recursive JSON (RJSON) introduction published on IMO best social news RSS-reader.

There is also available RJSON demo where you can convert any JSON data into RJSON format, decode result and ensure that it matches original JSON data.

Bellow you can see same document in both forms.

JSON

{
"id": 7,
"tags": ["programming", "javascript"],
"users": [
    {"first": "Homer", "last": "Simpson"},
    {"first": "Hank", "last": "Hill"},
    {"first": "Peter", "last": "Griffin"}
],
"books": [
    {"title": "JavaScript", "author": "Flanagan", "year": 2006},
    {"title": "Cascading Style Sheets", "author": "Meyer", "year": 2004}
]
}

RJSON

{
"id": 7,
"tags": ["programming", "javascript"],
"users": [
    {"first": "Homer", "last": "Simpson"},
    [2, "Hank", "Hill", "Peter", "Griffin"]
],
"books": [
    {"title": "JavaScript", "author": "Flanagan", "year": 2006},
    [3, "Cascading Style Sheets", "Meyer", 2004]
]
}

RJSON allows to:

  • decrease JSON data redundancy before the compression with tradition tools like gzip (for example see great tool jsonpickle or Twitter API output when length of field name often greater than leghth of the value itself).

  • reduce JSON data size and network traffic when gzip isn't available. For example, in-browser 3D-modeling tools like Mydeco 3D-planner may process and send to server megabytes of JSON-data;

  • analyze large collections of JSON-data without unpacking of whole dataset. RJSON-data is still JSON-data, so it can be traversed and analyzed after parsing and fully unpacked only if a document meets some conditions.

The above JSON vs RJSON example is based on the data structure from the JSON DB: a compressed JSON format. It's concept is implemented in JSONH - JSON Homogeneous Collections Compressor. RJSON provides similar level of data compression like JSONH does, but RJSON isn't limited to homogeneous collections only.

To run unit tests just open test/index.html in your browser or npm test if you have NodeJs installed.

For testing RJSON compression you can use bin/rjson script. It reads JSON/RJSON input from stdin and outputs RJSON/JSON to stdout. To unpack RJSON data try rjson -u. If you want to see some stat about comprerssion ratio and time, use rjson -v. With rjson -t you can active test mode in which script will compare restored and original data. For example:

$ cat ./test/fixtures/twitter_search100.json | rjson -v > ./100.rjson
In: 100523, Out: 64664, In/Out=155%, Time: 22ms (RJSON: 10ms).

$ cat ./100.rjson | rjson -uv > ./100.json
In: 64664, Out: 100523, In/Out=64%, Time: 21ms (RJSON: 4ms).

$ curl "http://search.twitter.com/search.json?q=Javascript&rpp=100&lang=en&include_entities=true" | rjson -vt > /dev/null
In: 103943, Out: 65763, In/Out=158%, Time: 32ms (RJSON: 18ms).

The code is available under Simplified BSD License, fell free to compress the world.