Code Monkey home page Code Monkey logo

js-bson's People

Contributors

dptole avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-bson's Issues

Interoperability with libbson

Round-trip encoding/decoding with js-bson works great, but I am having a rough time trying to exchange data with a client written in C using libbson from the MongoDB C driver.

According to the spec the first 4 bytes in a BSON document must be interpreted as an int32 with the total number of bytes comprising the document.

js-bson writes this header by taking the serialized string length:

return readAsInt32LE( bson.length + 5 ) + bson + '\x00';

The string's length property value is not necessarily equal to the number of bytes comprising the string:

console.log('\80\00'.length)
>> 3

console.log('\00\00'.length)
>> 2

When string length == string byte count libbson correctly deserializes documents, otherwise deserialization fails due to a validation check.

Does this make sense?

License?

Hi, and thanks for this great project. is it free and open source? If so, is it possible to add a license to the repository?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.