mongodb-extjson
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -108,3 +108,3 @@ var bsonModule = require('./bson') | ||
ExtJSON.prototype.deserialize = function(text, options) { | ||
ExtJSON.prototype.parse = function(text, options) { | ||
var self = this; | ||
@@ -132,3 +132,3 @@ options = options || { strict: true }; | ||
ExtJSON.prototype.serialize = function(value, reducer, indents) { | ||
ExtJSON.prototype.stringify = function(value, reducer, indents) { | ||
var doc = null; | ||
@@ -135,0 +135,0 @@ |
{ | ||
"name": "mongodb-extjson", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "MongoDB Extended JSON library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,3 +29,3 @@ # MongoDB Extended JSON Library | ||
### Serialize a document | ||
Serialize a document using `ExtJSON.prototype.serialize`. | ||
Serialize a document using `ExtJSON.prototype.stringify`. | ||
@@ -42,7 +42,7 @@ ```js | ||
console.log(ExtJSON.serialize(doc, null, 2)); | ||
console.log(ExtJSON.stringify(doc, null, 2)); | ||
``` | ||
### Deserialize a document | ||
Serialize a document using `ExtJSON.prototype.deseralize(string, options)`. The method supports the option `strict`. | ||
Serialize a document using `ExtJSON.prototype.parse(string, options)`. The method supports the option `strict`. | ||
@@ -65,7 +65,7 @@ ``` | ||
// Serialize the document | ||
var text = ExtJSON.serialize(doc, null, 2); | ||
var text = ExtJSON.stringify(doc, null, 2); | ||
// Deserialize using strict mode (returning BSON type objects) | ||
console.dir(ExtJSON.deserialize(text, {strict: true})); | ||
console.dir(ExtJSON.parse(text, {strict: true})); | ||
// Deserialize using strict mode (converting to native JS types where possible) | ||
console.dir(ExtJSON.deserialize(text, {strict: true})); | ||
console.dir(ExtJSON.parse(text, {strict: true})); | ||
``` | ||
@@ -77,3 +77,3 @@ | ||
### Serialize a document | ||
Serialize a document using `ExtJSON.prototype.serialize`. | ||
Serialize a document using `ExtJSON.prototype.stringify`. | ||
@@ -89,7 +89,7 @@ ```js | ||
console.log(ExtJSON.serialize(doc, null, 2)); | ||
console.log(ExtJSON.stringify(doc, null, 2)); | ||
``` | ||
### Deserialize a document | ||
Serialize a document using `ExtJSON.prototype.deseralize(string, options)`. The method supports the option `strict`. | ||
Serialize a document using `ExtJSON.prototype.parse(string, options)`. The method supports the option `strict`. | ||
@@ -111,7 +111,7 @@ ``` | ||
// Serialize the document | ||
var text = ExtJSON.serialize(doc, null, 2); | ||
var text = ExtJSON.stringify(doc, null, 2); | ||
// Deserialize using strict mode (returning BSON type objects) | ||
console.dir(ExtJSON.deserialize(text, {strict: true})); | ||
console.dir(ExtJSON.parse(text, {strict: true})); | ||
// Deserialize using strict mode (converting to native JS types where possible) | ||
console.dir(ExtJSON.deserialize(text, {strict: true})); | ||
console.dir(ExtJSON.parse(text, {strict: true})); | ||
``` |
@@ -106,3 +106,3 @@ var ExtJSON = require('../'), | ||
// Deserialize the document using non strict mode | ||
var doc1 = extJSON.deserialize(extJSON.serialize(nodeDoc, null, 0), {strict:false}); | ||
var doc1 = extJSON.parse(extJSON.stringify(nodeDoc, null, 0), {strict:false}); | ||
@@ -116,3 +116,3 @@ // Validate the values | ||
// Deserialize the document using strict mode | ||
var doc1 = extJSON.deserialize(JSON.stringify(nodeDoc, null, 0), {strict:true}); | ||
var doc1 = extJSON.parse(JSON.stringify(nodeDoc, null, 0), {strict:true}); | ||
@@ -133,3 +133,3 @@ // Validate the values | ||
// Deserialize the document using non strict mode | ||
var doc1 = extJSON.deserialize(extJSON.serialize(browserDoc, null, 0), {strict:false}); | ||
var doc1 = extJSON.parse(extJSON.stringify(browserDoc, null, 0), {strict:false}); | ||
@@ -143,3 +143,3 @@ // Validate the values | ||
// Deserialize the document using strict mode | ||
var doc1 = extJSON.deserialize(JSON.stringify(browserDoc, null, 0), {strict:true}); | ||
var doc1 = extJSON.parse(JSON.stringify(browserDoc, null, 0), {strict:true}); | ||
@@ -165,9 +165,9 @@ // Validate the values | ||
// Serialize the document | ||
var text = extJSON.serialize(doc1, null, 0); | ||
var text = extJSON.stringify(doc1, null, 0); | ||
assert.equal('{"int32":{"$numberInt":"10"}}', text); | ||
// Deserialize the json in strict and non strict mode | ||
var doc2 = extJSON.deserialize(text, {strict: true}); | ||
var doc2 = extJSON.parse(text, {strict: true}); | ||
assert.equal('Int32', doc2.int32._bsontype); | ||
doc2 = extJSON.deserialize(text, {strict: false}); | ||
doc2 = extJSON.parse(text, {strict: false}); | ||
assert.equal(10, doc2.int32); | ||
@@ -174,0 +174,0 @@ done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121368