Skip to content

Commit c7f56b8

Browse files
author
Adrian Tosca
committed
updated serialization doc in readme
1 parent 6a93b89 commit c7f56b8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,26 @@ val typeId = typeId().withUUIDGenerator { Generators.randomBasedGenerator().gene
221221
```
222222

223223

224-
### JSON serialization and deserialization
224+
### Serialization and deserialization
225+
226+
The ids have built-in serialization and deserialization support for Java, Kotlin (kotlinx.serialization), and Jackson.
227+
228+
229+
#### Kotlin (kotlinx.serialization)
230+
231+
Both [Id] and [RawId] have `@Serializable` and can be used with `kotlinx.serialization`.
232+
You need to include the actual serialization dependency in your project.
233+
234+
For example, with CBOR:
235+
236+
`include("io.github.microutils:kotlin-serialization-cbor:1.6.3")`
237+
238+
```kotlin
239+
val bytes = Cbor.encodeToByteArray<Id<User>>(id)
240+
val deserialized = Cbor.decodeFromByteArray<Id<User>>(bytes)
241+
```
242+
243+
#### Jackson
225244

226245
The library provides a Jackson module to serialize and deserialize `Id` instances.
227246

0 commit comments

Comments
 (0)