json-ex
Extends JSON to be able to serialize and deserialize more than just basic primitives
What is this?
Let's parse JSON like it is 20**! Let's add support for functions, buffers, dates and the basic primitives! If you know of anymore let me know and let's add them!
This is not a recreation of JSON, it is extending the protocol to allow for more types
Install
npm install json-ex
Usage
json-ex is a drop in replacement for JSON, so it implements JSON.stringify and JSON.parse
Stringify
const JSONex = ;const object = name: 'Hello world' person: true age: 100000 buffer: 'hi' date: '10/20/2017' { return 'hello world' } reg: '%name%';const output = JSONex;
output
``` ### Parse ```javascriptconst string = ``;const output = JSONex.parse(string);
output
name: 'Hello world' person: true age: 100000 buffer: <Buffer 68 69> date: 2017-10-20T07:00:00000Z func: Function: hello reg: /%name%/
Benchmark
run benchmarks by running
npm run benchmark
json-ex 41,763 op/s » Stringify 87,266 op/s » Parse Suites: 1Benches: 2Elapsed: 1,760.74 ms