# ddp-ejson

> Extended JSON as seen in Meteor and DDP

Latest version **0.8.1-3** (published 2014-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install ddp-ejson
pnpm add ddp-ejson
yarn add ddp-ejson
bun add ddp-ejson
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.1-3 |
| Published | 2014-05-24 |
| First published | 2014-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | emgee3 |
| Maintainers | emgee |
| Keywords | JSON, EJSON, serialization, meteor, ddp |

## Links

- npm: https://www.npmjs.com/package/ddp-ejson
- Repository: https://github.com/oortcloud/ddp-ejson
- Issues: https://github.com/oortcloud/ddp-ejson/issues
- npm.io page: https://npm.io/package/ddp-ejson

## Dependencies (1)

- [ddp-underscore-patched](https://npm.io/package/ddp-underscore-patched.md) 0.8.1-2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.8.1-3 (latest) — 2014-05-24
- 0.8.1-2 — 2014-05-14
- 0.8.1-1 — 2014-05-14

## README

ejson
=====

[![Build Status](https://travis-ci.org/oortcloud/ddp-ejson.svg)](https://travis-ci.org/oortcloud/ddp-ejson)

Extended JSON library; used in [Meteor](http://meteor.com)'s [Distributed Data Protocol](https://github.com/meteor/meteor/blob/devel/packages/livedata/DDP.md).


EJSON is a way of embedding more than the built-in JSON types in JSON.  It
supports all types built into JSON as plain JSON, plus the following:

**Dates:**

    {"$date": MILLISECONDS_SINCE_EPOCH}

**Binary data:**

    {"$binary": BASE_64_STRING}

(The base 64 string has `+` and `/` as characters 62 and 63, and has no maximum line length)

**Escaped things** that might otherwise look like EJSON types:

    {"$escape": THING}

For example, here is the JSON value `{$date: 10000}` stored in EJSON:

    {"$escape": {"$date": 10000}}

Note that escaping only causes keys to be literal for one level down; you can
have further EJSON inside.  For example, the following is the key `$date` mapped
to a Date object:

    {"$escape": {"$date": {"$date": 32491}}}

**User-specified types:**

    {"$type": TYPENAME, "$value": VALUE}


**Meteor ObjectIDs**

Support for the "oid" custom type used for Meteor ObjectIDs is built-in:

	{"$type": "oid", "$value": "c896e40bf6e51bbdc9adcf59"}

ObjectIDs may also be constructed:

```js
// Create a new Random ID
ObjID = new EJSON.ObjectID()

// Create an ID with a known value
myID = new EJSON.ObjectID("c896e40bf6e51bbdc9adcf59")
```

Implementations of EJSON should try to preserve key order where they can.  Users
of EJSON should not rely on key order, if possible.

> MongoDB relies on key order.  When using EJSON with MongoDB, the
> implementation of EJSON must preserve key order.

---
_Source: https://npm.io/package/ddp-ejson · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
