|
| 1 | +.. _kotlin-sync-bson: |
| 2 | + |
| 3 | +========================== |
| 4 | +Document Data Format: BSON |
| 5 | +========================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +Overview |
| 14 | +-------- |
| 15 | + |
| 16 | +In this guide, you can learn about the BSON data format, how MongoDB |
| 17 | +uses it, and how to install the BSON library independently of the |
| 18 | +{+driver-short+}. |
| 19 | + |
| 20 | +BSON Data Format |
| 21 | +---------------- |
| 22 | + |
| 23 | +**BSON**, or Binary JSON, is the data format that MongoDB uses to organize |
| 24 | +and store data. This data format includes all JSON data structure types and |
| 25 | +adds support for types including dates, differently-sized integers, ObjectIds, and |
| 26 | +binary data. For a complete list of supported types, see the |
| 27 | +:manual:`BSON Types </reference/bson-types>` server manual page. |
| 28 | + |
| 29 | +The binary format is not human-readable, but you can use the |
| 30 | +:ref:`BSON library <install-bson-library>` to convert it to the human-readable JSON |
| 31 | +representation. You can read more about the relationship between these |
| 32 | +formats in the :website:`JSON and BSON </json-and-bson>` guide on the MongoDB website. |
| 33 | + |
| 34 | +MongoDB and BSON |
| 35 | +---------------- |
| 36 | + |
| 37 | +You can use BSON data with your {+driver-short+} application by using one of the |
| 38 | +following object types that implements the `BSON interface <{+api+}/apidocs/bson/org/bson/conversions/Bson.html>`__: |
| 39 | + |
| 40 | +- `Document <{+api+}/apidocs/bson/org/bson/Document.html>`__ (BSON library package) |
| 41 | +- `BsonDocument <{+api+}/apidocs/bson/org/bson/BsonDocument.html>`__ (BSON library package) |
| 42 | +- `RawBsonDocument <{+api+}/apidocs/bson/org/bson/RawBsonDocument.html>`__ (BSON library package) |
| 43 | +- `JsonObject <{+api+}/apidocs/bson/org/bson/json/JsonObject.html>`__ (BSON library package) |
| 44 | + |
| 45 | +.. _install-bson-library: |
| 46 | + |
| 47 | +Install the BSON Library |
| 48 | +------------------------ |
| 49 | + |
| 50 | +These instructions detail how to add the BSON library as a dependency to |
| 51 | +your project. If you added the MongoDB Kotlin driver as a dependency to your |
| 52 | +project, you can skip this step since the BSON library is already included |
| 53 | +as a required dependency of the driver. |
| 54 | + |
| 55 | +.. TODO: For instructions on how to add the |
| 56 | +.. MongoDB Kotlin driver as a dependency to your project, see the |
| 57 | +.. :ref:`driver installation <kotlin-sync-download-install>` section of our Get Started |
| 58 | +.. guide. |
| 59 | + |
| 60 | +We recommend that you use the `Maven <https://maven.apache.org/>`__ or |
| 61 | +`Gradle <https://gradle.org/>`__ build automation tool to manage your project's |
| 62 | +dependencies. Select from the following tabs to see the dependency declaration |
| 63 | +for that tool: |
| 64 | + |
| 65 | +.. tabs:: |
| 66 | + |
| 67 | + .. tab:: Maven |
| 68 | + :tabid: maven-dependencies |
| 69 | + |
| 70 | + The following snippet shows the dependency declaration in the |
| 71 | + ``dependencies`` section of your ``pom.xml`` file. |
| 72 | + |
| 73 | + .. include:: /includes/data-formats/bson-maven-versioned.rst |
| 74 | + |
| 75 | + .. tab:: Gradle |
| 76 | + :tabid: gradle-dependencies |
| 77 | + |
| 78 | + The following snippet shows the dependency declaration in the |
| 79 | + ``dependencies`` object in your ``build.gradle`` file. |
| 80 | + |
| 81 | + .. include:: /includes/data-formats/bson-gradle-versioned.rst |
| 82 | + |
| 83 | +If you are not using one of the preceding tools, you can include it in |
| 84 | +your project by downloading the JAR file directly from the |
| 85 | +`sonatype repository <https://repo1.maven.org/maven2/org/mongodb/bson/>`__. |
0 commit comments