Skip to content

Commit

Permalink
README.md code syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
subchannel13 authored Feb 10, 2025
1 parent 007ec9c commit 06a45f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![GitHub Sponsors](https://img.shields.io/github/sponsors/subchannel13)

Serialization library that handles circular references and cross module polymorphism with just annotations.
```
```Kotlin
@SerializableClass
abstract class BaseClass(
@SerializationData val foo: String
Expand Down Expand Up @@ -32,7 +32,7 @@ Additionally serialization and deserialization work in two stages

Serialization works in two stages: packing and serialization proper. Packing stage converts concrete objects to generic maps and lists that can then be serialized to a format of choice.

```
```Kotlin
// Object to serialize
val obj = ObjectSample(10)

Expand All @@ -52,7 +52,7 @@ session.referencedData.forEach {
To start serialization you need a fresh instance of `PackingSession` and call `pack` on and an appropriate packer class (generated for `@SerializableClass` annotated class). This will populate the packing session and return the reference of the "root" object. Then you can use those data to create output in the format of choice. This does move require from library user to write that final piece of logic, but that is not as complex as it sounds. Here is an example of `serializationMapper` function for converting packed objects to JSON for Android:


```
```Kotlin
fun serializationMapper(obj: Any, path: String = ""): Any = when(obj) {
is Map<*, *> -> JSONArray().apply {
put("map")
Expand Down

0 comments on commit 06a45f8

Please sign in to comment.