diff --git a/docs/guide.md b/docs/guide.md index 0bc47e89..be98e3cd 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -555,7 +555,7 @@ The collection is called `boskCollection` and the document has four fields: The format of the `state` field is determined by `BsonPlugin`. The code for `BsonPlugin` will have the details, but some high-level points about the BSON format: -- It does not match the JSON format generated by `bosk-gson`. The two are not mutually compatible. This is a deliberate decision based on differing requirements. +- It does not match the JSON format generated by `bosk-jackson` or `bosk-gson`. This is a deliberate decision based on differing requirements. - It strongly favours objects over arrays, because object members offer idempotency and (ironically) stronger ordering guarantees. ##### Schema evolution: how to add a new field @@ -621,11 +621,27 @@ These rules require that the driver maintains an awareness of the current bosk s and so most drivers are rarely able to take advantage of these options, because they can't generally determine what effect an update will have. -### Serialization: `bosk-gson` +### Serialization: `bosk-jackson` and `bosk-gson` -The `bosk-gson` module uses the Gson library to support JSON serialization and deserialization. +The `bosk-jackson` and `bosk-gson` modules use the Jackson and Gson libraries to support JSON serialization and deserialization. -#### Configuring the Gson object +#### Configuring Jackson + +To configure an `ObjectMapper` that is compatible with a particular `Bosk` object, use the `JacksonPlugin.moduleFor` method. +Here is an example: + +``` java +JacksonPlugin jacksonPlugin = new JacksonPlugin(); +boskMapper = new ObjectMapper() + .registerModule(jacksonPlugin.moduleFor(bosk)) + + // You can add whatever configuration suits your application: + .enable(INDENT_OUTPUT); +``` + +`JacksonPlugin` is compatible with many of the `ObjectMapper` configuration options, so you should be able to configure it as you want. + +#### Configuring Gson To configure a `Gson` object that is compatible with a particular `Bosk` object, use the `GsonPlugin.adaptersFor` method. Here is an example: @@ -636,14 +652,14 @@ boskGson = new GsonBuilder() .registerTypeAdapterFactory(gsonPlugin.adaptersFor(bosk)) // You can add whatever configuration suits your application. - // We recommend these. + // We recommend these: .excludeFieldsWithoutExposeAnnotation() .setPrettyPrinting() .create(); ``` -Note that `GsonPlugin` is compatible with many of the Gson configuration options, so you should be able to configure it as you want. +`GsonPlugin` is compatible with many of the Gson configuration options, so you should be able to configure it as you want. #### Format