ejson2
v1.1.0
Published
Extended JSON Evolved
Downloads
270
Maintainers
Readme
EJSON 2
This library allows stringifying objects while preserving some object types on parse, like Dates, Binary and also custom types defined by the user.
This is an improved version of the original ejson
library from Meteor:
- Cloned from the Meteor repo and converted the entire codebase to TypeScript and Vitest.
- Now it eliminates circular references automatically.
- Added
base64-js
for handling binary data instead of maintaing own code. - Removed Meteor specific code references.
All tests have been converted to Vitest and all of them pass, including new tests added.
Roadmap
- Add types to the entire codebase.
- Performance improvements as needed.
Mongoose
If you work with Mongoose now this library automatically converts ObjectId
s to strings.
Installation
yarn add ejson2
or
npm install ejson2
Usage
import { EJSON } from 'ejson2'
EJSON.parse('{}')
EJSON.stringify({})