@3xpo/microjson
v1.0.5
Published
A pure TypeScript JSON parser
Downloads
18
Readme
MicroJSON
A JSON implementation quickly thrown together.
Example
import { JSONParser, JSONSerializer } from '@3xpo/microjson';
// parser:
const parser = new JSONParser();
console.log(parser.parse<{
hello: string; // this object is optional, however it allows specifying detailed types for the return value without casting
}>('{"hello": "world"}'));
// serializer:
const serializer = new JSONSerializer();
console.log(serializer.serialize({ hello: 'world' }));
As a polyfill
import JSON from '@3xpo/microjson/polyfill';
console.log(JSON.parse<{
hello: string; // yet again, this object is optional, however it allows specifying detailed types for the return value without casting
}>('{"hello": "world"}'));
console.log(JSON.stringify({ hello: 'world' }, null, 2));
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Tests & JSDoc were written using ChatGPT because I'm lazy.
License
This project is licensed under the MIT license. See LICENSE for more information.