Package Exports
- @quiui/x-json
- @quiui/x-json/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@quiui/x-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
XJSON
Add circual reference auto solving capabilities to JSON.parse() and JSON.stringify() functions, licensed under MIT license.
Install
npm i @quiui/x-jsonUsage
You can use this lib by calling it directly or by "installing" it over the global JSON.
Directly calling
const XJSON = require('@quiui/x-json');
const person = {name: 'foo', lastName: 'bar'};
console.log(XJSON.stringify(person));
// OUTPUT: {"name":"foo","lastName":"bar"}
const person2 = XJSON.parse('{"name":"Bar","lastName":"Foo"}');
// person2: {name: "Bar", lastName: "Foo"}Installing it over the global JSON
const XJSON = require('@quiui/x-json');
// Installs XJSON over JSON
XJSON.replaceJSON();
const person = {name: 'foo', lastName: 'bar'};
// Note that now you can call XJSON by using global JSON
console.log(JSON.stringify(person));
// OUTPUT: {"name":"foo","lastName":"bar"}
const person2 = JSON.parse('{"name":"Bar","lastName":"Foo"}');
// person2: {name: "Bar", lastName: "Foo"}
// You can reverte XJSON installation anytime
XJSON.restoreJSON();Limitations
XJSON.parse() and XJSON.stringify() functions only accept one argument: "value". There's no way to pass a reviver function to it, or any other options. We thank you if you can help improve our library ;)