Data Formats

For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

Data Formats

Overview

The Kotlin Sync driver supports the kotlinx.serialization library for serializing and deserializing Kotlin objects. You can use this library to convert between MongoDB documents and different data formats in your application. To learn more about serialization, see the [Data Serialization](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/serialization.md#std-label-kotlin-sync-serialization guide.

As an alternative to using Kotlin serialization, you can define and implement custom Codec types to support encoding and decoding of your Kotlin objects. To learn more, see the [Encode Data with Type Codecs](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/codecs.md#std-label-kotlin-sync-codecs guide.

You can use several types of specialized document data formats in your application. To learn how to work with these data formats, see the following sections:

  • Learn how to model your documents as Kotlin data classes in the [Document Data Format: Data Classes](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/data-format-data-class.md#std-label-kotlin-sync-data-format-data-classes guide.

  • Learn how to work with the BSON data format in the [Work with BSON Data](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/bson.md#std-label-kotlin-sync-bson guide.

  • Learn how to store and interact with time series data in the [Time Series Collections](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/time-series.md#std-label-kotlin-sync-time-series guide.

  • Learn how to read and write Extended JSON strings in the [Work with Extended JSON Data](https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/data-formats/extended-json.md#std-label-kotlin-sync-extended-json guide.