Skip to content

Commit 760109a

Browse files
committed
MW PR fixes 1
1 parent 67bcfc4 commit 760109a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

source/fundamentals/data-formats/serialization.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ work with date and time types.
313313
kotlinx-datetime Library
314314
~~~~~~~~~~~~~~~~~~~~~~~~
315315

316-
``kotlinx-datetime`` is a {+language+} library that allows
317-
you to work with dates and times. If you want a high level of control
318-
over how your date and time values are serialized, you can add the
316+
``kotlinx-datetime`` is a {+language+} library that offers
317+
a high level of control over how your date and time values
318+
are serialized. To use the library, add the ``kotlinx-datetime``
319319
dependency to your project's dependency list.
320320

321321
Select from the following tabs to see how to add the ``kotlinx-datetime``
@@ -354,11 +354,17 @@ After you add the library dependency, you can implement serializers from
354354
the ``kotlinx-datetime`` library that map your data class field values
355355
to the expected types in BSON.
356356

357-
The following ``Appointment`` data class has the ``@Serializable``
358-
annotation and the ``@Contextual`` annotation on the ``date`` field
359-
to use the ``kotlinx-datetime`` serializer for ``LocalDate`` values.
360-
Values of the ``time`` field are stored as strings, because the driver
361-
does not use a serializer without the ``@Contextual`` annotation:
357+
In the following example, the driver serializes the fields of
358+
the ``Appointment`` data class with the following behavior:
359+
360+
- ``name``: The driver serializes the value as a string.
361+
362+
- ``date``: The driver uses the ``kotlinx-datetime`` serializer
363+
because the field has the ``@Contextual`` annotation. So,
364+
``LocalDate`` values are serialized as BSON dates.
365+
366+
- ``time``: The driver serializes the value as a string because it does
367+
not have the ``@Contextual`` annotation.
362368

363369
.. literalinclude:: /examples/generated/KotlinXSerializationTest.snippet.datetime-data-class.kt
364370
:language: kotlin
@@ -370,7 +376,7 @@ class into MongoDB:
370376
:language: kotlin
371377

372378
In MongoDB, the ``LocalDate`` value is stored as a BSON date, and the
373-
``time`` field is stored by using default serialization as a string:
379+
``time`` field is stored as a string by default serialization:
374380

375381
.. code-block:: json
376382

source/whats-new.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ improvements, and fixes:
3636
:ref:`kotlin-search-indexes` in the Indexes guide
3737

3838
- Adds support for serializers from the ``kotlinx-datetime`` library
39-
that let you map to BSON as the expected types instead of as strings.
40-
To learn more, see the :ref:`kotlin-datetime-serialization` section of
41-
the Kotlin Serialization guide.
39+
that let you map {+language+} date and time types to BSON as the
40+
expected types instead of as strings. To learn more, see the
41+
:ref:`kotlin-datetime-serialization` section of the {+language+}
42+
Serialization guide.
4243

4344
.. _kotlin-coroutine-version-5.1.3:
4445

0 commit comments

Comments
 (0)