BSON (.bson)

Background & Context

    • JSON-like binary serialization.
    • Schemaless format.
    • Represent document as ordered key/value pairs.

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.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"list of rules for all available elements


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:

Import as an expression: