Skip to content

Commit 0755450

Browse files
author
Chris Cho
authored
Merge pull request #36 from ccho-mongodb/DOCSP-12156-data-format-bson
DOCSP-12156: BSON Data Format
2 parents 99fede9 + 996bc32 commit 0755450

File tree

4 files changed

+92
-10
lines changed

4 files changed

+92
-10
lines changed

source/fundamentals/data-formats/document-data-format-bson.txt

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,75 @@ Document Data Format: BSON
1313
Overview
1414
--------
1515

16-
- Definition of BSON format, where it's used, why it's used.
17-
- Link to more info on BSON
18-
- What information you can find in the following sections
16+
This guide explains the BSON data format, how MongoDB uses it, and how to
17+
install the BSON library independently of the MongoDB driver.
1918

20-
Installation
21-
------------
19+
BSON Data Format
20+
----------------
2221

23-
- Instructions on how to add the dependency with Maven or Gradle
22+
**BSON**, or Binary JSON, is the data format that MongoDB uses to organize
23+
and store data. This data format includes all JSON data structure types and
24+
adds support for types including dates, different size integers, ObjectIds, and
25+
binary data. For a complete list of supported types, see the
26+
:manual:`BSON Types </reference/bson-types>` server manual page.
27+
28+
The binary format is not human-readable, but you can use the
29+
:ref:`Java BSON library <install-bson-library>` to convert it to a JSON
30+
representation. You can read more about the relationship between these
31+
formats in our article on :website:`JSON and BSON </json-and-bson>`.
32+
33+
MongoDB and BSON
34+
----------------
35+
36+
The MongoDB Java Driver, which uses the BSON library, allows you to work
37+
with BSON data by using one of the object types that implement the
38+
:java-docs:`Bson <apidocs/bson/org/bson/conversions/Bson.html>` interface,
39+
including:
40+
41+
- :java-docs:`Document <apidocs/bson/org/bson/Document.html>` (BSON library package)
42+
- :java-docs:`BsonDocument <apidocs/bson/org/bson/BsonDocument.html>` (BSON library package)
43+
- :java-docs:`RawBsonDocument <apidocs/bson/org/bson/RawBsonDocument.html>` (BSON library package)
44+
- :java-docs:`BasicDBObject <apidocs/mongodb-driver-core/com/mongodb/BasicDBObject.html>` (Java Driver package)
45+
46+
For more information on using these object types, see our
47+
:doc:`Documents guide <fundamentals/data-formats/documents>`.
48+
49+
.. _install-bson-library:
50+
51+
Install the BSON Library
52+
------------------------
53+
54+
These instructions show you how to add the BSON library as a dependency to
55+
your project. If you added the MongoDB Java driver as a dependency to your
56+
project, you can skip this step since the BSON library is already included
57+
as a required dependency of the driver. For instructions on how to add the
58+
MongoDB driver as a dependency to your project, see the
59+
:ref:`driver installation <add-mongodb-dependency>` section of our Quick Start
60+
guide.
61+
62+
We recommend that you use the `Maven <https://maven.apache.org/>`__ or
63+
`Gradle <https://gradle.org/>`__ build automation tool to manage your project
64+
dependencies. Select from the tabs below to see the dependency declaration
65+
for that tool:
66+
67+
.. tabs::
68+
69+
.. tab:: Maven
70+
:tabid: maven-dependencies
71+
72+
The following snippet shows the dependency declaration in the
73+
``dependencies`` section of your ``pom.xml`` file.
74+
75+
.. include:: /includes/fundamentals/code-snippets/bson-maven-versioned.rst
76+
77+
.. tab:: Gradle
78+
:tabid: gradle-dependencies
79+
80+
The following snippet shows the dependency declaration in the
81+
``dependencies`` object in your ``build.gradle`` file.
82+
83+
.. include:: /includes/fundamentals/code-snippets/bson-gradle-versioned.rst
84+
85+
If you are not using one of the tools listed above, you can include it in
86+
your project by downloading the JAR file directly from the
87+
`sonatype repository <https://repo1.maven.org/maven2/org/mongodb/bson/>`__.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. code-block:: groovy
2+
3+
dependencies {
4+
compile 'org.mongodb:bson:4.1.0'
5+
}
6+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. code-block:: xml
2+
3+
<dependencies>
4+
<dependency>
5+
<groupId>org.mongodb</groupId>
6+
<artifactId>bson</artifactId>
7+
<version>4.1.0</version>
8+
</dependency>
9+
</dependencies>
10+

source/quick-start.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ Create the Project
2525

2626
.. include:: /includes/quick-start/create-project.rst
2727

28+
.. _add-mongodb-dependency:
29+
2830
Add MongoDB as a Dependency
2931
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3032

31-
If you are using Maven, add the following to your ``pom.xml`` dependencies
32-
list:
33+
If you are using `Maven <https://maven.apache.org/>`__, add the following to
34+
your ``pom.xml`` dependencies list:
3335

3436
.. code-block:: xml
3537

@@ -41,8 +43,8 @@ list:
4143
</dependency>
4244
</dependencies>
4345

44-
If you are using Gradle, add the following to your ``build.gradle``
45-
dependencies list:
46+
If you are using `Gradle <https://gradle.org/>`__, add the following to your
47+
``build.gradle`` dependencies list:
4648

4749
.. code-block:: groovy
4850

0 commit comments

Comments
 (0)