Name: js-bson
Owner: Meteor
Description: null
Created: 2013-07-18 17:53:54.0
Updated: 2015-03-04 00:14:14.0
Pushed: 2015-02-07 01:50:58.0
Homepage: null
Size: 786
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This BSON parser is primarily meant for usage with the mongodb
node.js driver. However thanks to such wonderful tools at onejs
we are able to package up a BSON parser that will work in the browser aswell. The current build is located in the browser_build/bson.js
file.
A simple example on how to use it
<head>
<script src="https://raw.github.com/mongodb/js-bson/master/browser_build/bson.js">
</script>
</head>
<body onload="start();">
<script>
function start() {
var BSON = bson().BSON;
var Long = bson().Long;
var doc = {long: Long.fromNumber(100)}
// Serialize a document
var data = BSON.serialize(doc, false, true, false);
// De serialize it again
var doc_2 = BSON.deserialize(data);
}
</script>
</body>
It's got two simple methods to use in your application.
BSON.serialize(object, checkKeys, asBuffer, serializeFunctions)
BSON.deserialize(buffer, options, isArray)