3.2.0 • Published 8 months ago

superjsonatural v3.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

SuperJSONatural ~9kB

Truly one of the world faster serializer/parser on the web

SuperJSONatural branding logo

Information :mag:

MIT

JSON yet, somehow lighter & faster with the support of all JS TypedArray! It uses a Base64 optimized algorithm... when you use stringify and parse

And for pack/unpack usage, it is binary serialization which use a JSON tree and lookup table which refer to a buffer appended to the json also encoded inside a buffer using TextEncoder(), up to 5x faster and somehow significally faster than the trusted CBOR-X while being 3.5x lighter! Check the demo ;)

If you use larger TypedArray than buffer, simply use pack/unpack and work with ArrayBuffer. Meanwhile if you can't, the good old stringify/parse function will works fine based on String!

npm

DEMO : Go to codepen.io :sparkles:

Performances ( 1000 x 16kB )

NPM PackagePackingUnpacking
OURS182ms144ms
CBOR-X202ms (+8%)246ms (+70%)

Stringify takes 92ms while parsing take 255ms when it comes to working with string instead of the above BytesArray packing/unpacking methods, still worth the move!

Install :package:

Download it from NPM easily

Run :

+ npm install superjsonatural

And you get that piece of technology for JSON parsing!

How to use it? :wrench:

import SuperJSONatural from "superjsonatural"; // In node.js
/* OR */
var SuperJSONatural = window.SuperJSONatural; // Use the minified version for browser (> safari 10 & > Chrome 51)

var data = {
    name: "Prof. Bernice Champlin Jr.",
    male: true,
    female: false,
    timestamp: Date.now(),
    hair: Uint8Array.of(0, 55, 77, 65, 9, 1, 1, 1, 1, 200, 44, 22, 9, 0),
    email: "stevie.conn@luettgen.com",
    phone: 3476774277,
    description: "Et voluptatem incidunt repellat. Qui laboriosam quis accusamus optio sed. Non qui qui quasi aliquid.",
	other: {
		ANARRAY: ["lol", 99],
		prop: 992,
		str: "str",
		hair: Uint32Array.of(999)
	}
};

// It will be a string when encoded, always
var encoded = SuperJSONatural().stringify(data);
var decoded = SuperJSONatural().parse(encoded);
console.log(data, encoded, decoded)

// NEW!!! It will be a Uint8Array (Like a bytes array buffer)
var encoded = SuperJSONatural().pack(data);
var decoded = SuperJSONatural().unpack(encoded);
console.log(data, encoded, decoded)
3.2.0

8 months ago

3.1.1

8 months ago

3.1.0

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.6.0

1 year ago

2.5.2

1 year ago

2.5.1

1 year ago

2.5.0

1 year ago

2.4.0

1 year ago

2.3.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago