Package Exports
- mongodb-extended-json
- mongodb-extended-json/lib/types
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mongodb-extended-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mongodb-extended-json
MongoDB Extended JSON parse and stringify that is friendly with bson and is actually compliant with the kernel.
Example
var EJSON = require('mongodb-extended-json');
var BSON = require('bson');
var doc = {
_id: BSON.ObjectID(),
last_seen_at: new Date(),
display_name: undefined
};
console.log('Doc', doc);
// > Doc { _id: 53c2ab5e4291b17b666d742a, last_seen_at: Sun Jul 13 2014 11:53:02 GMT-0400 (EDT), display_name: undefined }
console.log('JSON', JSON.stringify(doc));
// > JSON {"_id":"53c2ab5e4291b17b666d742a","last_seen_at":"2014-07-13T15:53:02.008Z"}
console.log('EJSON', EJSON.stringify(doc));
// > EJSON {"_id":{"$oid":"53c2ab5e4291b17b666d742a"},"last_seen_at":{"$date":1405266782008},"display_name":{"$undefined":true}}
// And likewise, EJSON.parse works just as you would expect.
EJSON.parse('{"_id":{"$oid":"53c2ab5e4291b17b666d742a"},"last_seen_at":{"$date":1405266782008},"display_name":{"$undefined":true}}');
// { _id: 53c2ab5e4291b17b666d742a,
// last_seen_at: Sun Jul 13 2014 11:53:02 GMT-0400 (EDT),
// display_name: undefined }