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 Bun.
- Add types to the entire codebase.
- Performance improvements as needed.
If you work with Mongoose now this library automatically converts ObjectId
s to strings.
yarn add ejson2
or
npm install ejson2
import { EJSON } from 'ejson2'
EJSON.parse('{}')
EJSON.stringify({})