0.5.15 • Published 11 months ago
@brillout/json-serializer v0.5.15
@brillout/json-serializer
Same as JSON but with added support for:
DateundefinedSetMapBigIntRegExpNaNInfinity
JSON is a good serializer for JavaScript values but
is lacking some JavaScript types such as Date:
!INLINE /examples/date_json.js --hide-source-pathWhereas with @brillout/json-serializer:
!INLINE /examples/date_json-serializer.js --hide-source-pathContents
Usage
!INLINE /examples/simple.js --hide-source-pathFull Example
Example exposing all differences between JSON and @brillout/json-serializer.
!INLINE /examples/json-serializer.jsTo run the example:
$ git clone git@github.com:brillout/json-serializer
$ cd json-serializer
$ npm install
$ npm run self-link
$ node ./examples/json-serializer.jsThe npm run self-link is required to be able to self require('@brillout/json-serializer').
How it Works
Let's see how @brillout/json-serializer serializes an object:
!INLINE /examples/inspect.js@brillout/json-serializer is based on JSON while using prefixed strings for unsupported types.
@brillout/json-serializer uses the native JSON.parse and JSON.stringify functions while modifying the serialization of unsupported types.