The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

BSON Corpus

This BSON test data corpus consists of a JSON file for each BSON type, plus a top.json file for testing the overall, enclosing document.

Top level keys include:

Valid test case keys include:

Decode error cases provide an invalid BSON document or field that should result in an error. For each case, keys include:

Parse error cases are type-specific and represent some input that can not be encoded to the bson_type under test. For each case, keys include:

Extended JSON extensions

The extended JSON documentation doesn't include extensions for all BSON types. These are supported by mongoexport:

# Javascript
{ "$code": "<code here>" }

# Javascript with scope
{ "$code": "<code here>": "$scope": { "x":1, "y":1 } }

# Int32
{ "$numberInt": "<number>" }

However, this corpus extends JSON further to include the following:

# Double (needed for NaN, etc.)
{ "$numberDouble": "<value|NaN|Inf|-Inf>" }

# DBpointer (deprecated): <id> is 24 hex chars
{ "$dbpointer": "<id>", "$ns":"<namespace>" }

# Symbol (deprecated)
{ "$symbol": "<text>" }

Visualizing BSON

The directory includes a Perl script bsonview, which will decompose and highlight elements of a BSON document. It may be used like this:

echo "0900000010610005000000" | perl bsonview -x

Open Questions

These issues are still TBD: