JSPM

@rickyli79/rich-json

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q43900F
  • License MIT

Serialize and Deserialize javascript objects

Package Exports

  • @rickyli79/rich-json
  • @rickyli79/rich-json/bin/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 (@rickyli79/rich-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rickyli79/rich-json

serialize and deserialize rich javascript data types, suport reference data.

install

npm install @rickyli79/rich-json

usage

supported runtime

  • NodeJS
  • Browser

stringify

import RichJson from '@rickyli79/rich-json'
// const RichJson = require('@rickyli79/rich-json');
const complexObj_origin = { key: 'any supported data types' };
const rJson:string = RichJson.stringify(complexObj_origin);
// todo: save rJson to file;

parse

import RichJson from '@rickyli79/rich-json'
const rJson:string = getRichJsonText();
const complexObj = RichJson.parse<TComplaxObj>(rJson);

clone

import RichJson from '@rickyli79/rich-json'
const complexObj_origin = { key: 'any supported data types' };
const complexObj = RichJson.clone(complexObj_origin);

assert.notStrictEqual(complexObj, complexObj_origin);

supported data types

  • primitive
    • null
    • undefined
    • bigint
    • number
      • normal
      • NaN
      • -0
      • Number.EPSILON
      • Number.MAX_SAFE_INTEGER
      • Number.MIN_SAFE_INTEGER
      • Number.NEGATIVE_INFINITY
      • Number.POSITIVE_INFINITY
  • function
    • function
    • async function
    • arrow function
    • async arrow function
  • object
    • URL
    • Date
    • RegExp
    • Set
    • Map
    • Error ( with message only, without stack )
    • Buffer like
      • Buffer in NodeJs
      • Int8Arrany, Uint16Array, Uint32Array ...and more
      • NOT support Blob
    • WrapRunner class
    • customer serializers
  • reference
    • reference to same object
    • circular reference

      including reference in Set and Map, and WrapRunner class or customer serializers

unittest