This library adds support for BSON to the Jackson JSON processor.
BSON is a binary representation of JSON. It is well known as the main exchange and persistence format of MongoDB.
Quick start
Just create a Jackson ObjectMapper
with a BsonFactory
as follows:
ObjectMapper mapper = new ObjectMapper(new BsonFactory());
For more information, you may read my bson4jackson tutorial or the complete documentation of Jackson.
Download
bson4jackson binaries are available from the GitHub releases page.
You may also use Maven to download bson4jackson:
<dependencies>
<dependency>
<groupId>de.undercouch</groupId>
<artifactId>bson4jackson</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
If you are using Gradle, you may add the following snippet to your build.gradle
:
dependencies {
compile 'de.undercouch:bson4jackson:2.9.2'
}
Compatibility
bson4jackson 2.x is compatible to Jackson 2.x and higher. Due to some compatibility issues, both libraries' major and minor version numbers should match. That means you should use at least bson4jackson 2.1 if you use Jackson 2.1, bson4jackson 2.2 if you use Jackson 2.2, etc. I will try to keep bson4jackson up to date. If there is a compatibility issue I will update it, usually within a couple of days after the new Jackson version has been released.
Here is the compatibility matrix for the current library versions:
Library | Jackson 2.9.x | Jackson 2.8.x | Jackson 2.7.x | Jackson 2.6.x | Jackson 2.5.x |
---|---|---|---|---|---|
bson4jackson 2.9.x | Yes | Yes | Yes | Yes | Yes |
bson4jackson 2.8.x | Yes | Yes | Yes | Yes | Yes |
bson4jackson 2.7.x | Yes | Yes | Yes | Yes | Yes |
bson4jackson 2.6.x | No | No | No | Yes | Yes |
If you are looking for a version compatible to Jackson 1.x, please use bson4jackson 1.3.0. It's the last version for the 1.x branch. bson4jackson 1.3.0 is compatible to Jackson 1.7 up to 1.9.
Compiling
Execute the following command to compile the library and to run the unit tests:
./gradlew test
The script automatically downloads the correct Gradle version so you won't have to do anything else. If everything runs successfully, you may create a .jar library:
./gradlew jar
The library will be located under build/libs
.
License
bson4jackson is licensed under the Apache License, Version 2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.