https://github.com/primus/ejson
EJSON - Extended JSON from Meteor available for Node.js and the front-end in one handy neat package. Made compatible for Primus.
https://github.com/primus/ejson
Last synced: about 1 year ago
JSON representation
EJSON - Extended JSON from Meteor available for Node.js and the front-end in one handy neat package. Made compatible for Primus.
- Host: GitHub
- URL: https://github.com/primus/ejson
- Owner: primus
- License: mit
- Created: 2013-08-16T14:29:13.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T16:54:33.000Z (over 3 years ago)
- Last Synced: 2025-03-15T06:08:59.441Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 87
- Watchers: 5
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ejson
[](https://www.npmjs.com/package/ejson)[](https://github.com/primus/ejson/actions?query=workflow%3ACI+branch%3Amaster)[](https://coveralls.io/r/primus/ejson?branch=master)
`ejson` is an extension of JSON to support more types. It supports all JSON-safe
types as well as
- **Date**: It maintains a date instance instead of transforming it to a string.
- **Binary**: `Uint8Array`
- **User defined types**
The `ejson` module is port of Meteor's EJSON parser which has been made
compatible for Node.js and browsers. This way, other
[real-time libraries](https://github.com/primus/primus) can also make use of
these extensions.
## Installation
The module is released through npm:
```
npm install --save ejson
```
## Usage
The API is exactly the same as the API that Meteor provides as it uses exactly
the same code. The most important API's are:
- `EJSON.clone`
- `EJSON.parse`
- `EJSON.stringify`
And some utility methods:
- `EJSON.toJSONValue`
- `EJSON.fromJSONValue`
- `EJSON.isBinary`
- `EJSON.newBinary`
- `EJSON.equals`
See the [meteor EJSON documentation](https://docs.meteor.com/#ejson) for more
detailed information.
## License
This module is licensed under MIT. Same as Meteor.js is.