EJSON

From air
Jump to: navigation, search

https://www.meteor.com/ejson

EJSON is a backward-compatible extension to JSON that adds Date and Binary types.

Examples

> EJSON.stringify({ when: new Date })
"{"when":{"$date":1412884295442}}"

> EJSON.stringify({ imageData: new Uint8Array(10) })
"{"imageData":{"$binary":"AAAAAAAAAAAAAA=="}}"

> EJSON.stringify({$date: "something"})
"{"$escape":{"$date":"something"}}"

> EJSON.stringify({_id: new Mongo.ObjectID})
"{"_id":{"$type":"oid","$value":"34c420c028fb169c31041ab0"}}"