BSON (.bson)
Background & Context

-
- JSON-like binary serialization.
- Schemaless format.
- Represent document as ordered key/value pairs.
- Format used to store data in MongoDB.
- BSON is specified at http://bsonspec.org.
Import & Export


- Import["file.bson"] imports a BSON file as an association.
- ImportString["string","BSON"] imports a BSON string of bytes.
- Export["file",assoc,"BSON"] exports an association to a BSON file.
- ExportString[assoc,"BSON"] exports to a BSON string of bytes.
- The "BSON" format identifies BSON documents with associations of the Wolfram Language.
- The MongoDB database stores data as BSON documents.
- A BSON document is a list of key/value pairs. The keys of the association must be strings, and values must be one of the following types:
-
BSONObjectID object id Association object BSONDecimal128 high-precision number ByteArray binary data DateObject date Infinity max key Integer 64-bit integer List array Minus[Infinity] min key Null null Real double String string True,False Boolean - See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements

- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements
Examples
Basic Examples (2)
Export an association as a BSON document:
Import the resulting string of bytes as an expression:
DateObject is supported in the BSON format: