@@ -173,7 +173,8 @@ package to create a codec for your ``@Serializable`` data classes and
173173customize what is stored.
174174
175175Use the ``BsonConfiguration`` class to define the configuration,
176- including whether to encode defaults, encode nulls, or define class discriminators.
176+ including whether to encode defaults, encode nulls, define class discriminators,
177+ or enforce snake case.
177178
178179To create a custom codec, install the ``bson-kotlinx``
179180dependency to your project. Select from the following tabs to see how to
@@ -241,12 +242,28 @@ The following example shows how to create a codec using the
241242.. literalinclude:: /examples/generated/KotlinXSerializationTest.snippet.custom-serialization.kt
242243 :language: kotlin
243244
245+ Enforcing Snake Case Naming Example
246+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247+
248+ The following example shows how to convert field names from their data class
249+ fields into snake case by setting the ``bsonNamingStrategy`` parameter:
250+
251+ .. code-block:: kotlin
252+ :copyable: true
253+
254+ import org.bson.codecs.kotlinx.BsonConfiguration
255+ import org.bson.codecs.kotlinx.BsonNamingStrategy
256+
257+ .. literalinclude:: /examples/generated/KotlinXSerializationTest.snippet.snake-case-serialization.kt
258+ :language: kotlin
259+
244260For more information about the methods and classes mentioned in this section,
245261see the following API documentation:
246262
247263- `KotlinSerializerCodec <{+api-root+}/bson-kotlinx/bson-kotlinx/org.bson.codecs.kotlinx/-kotlin-serializer-codec/index.html>`__
248264- `KotlinSerializerCodec.create() <{+api-root+}/bson-kotlinx/bson-kotlinx/org.bson.codecs.kotlinx/-kotlin-serializer-codec/-companion/create.html>`__
249265- `BsonConfiguration <{+api-root+}/bson-kotlinx/bson-kotlinx/org.bson.codecs.kotlinx/-bson-configuration/index.html>`__
266+ - `BsonNamingStrategy <{+api-root+}/bson-kotlinx/bson-kotlinx/org.bson.codecs.kotlinx/-bson-naming-strategy/index.html>`__
250267
251268.. _kotlin-polymorphic:
252269
0 commit comments