@@ -13,6 +13,30 @@ import java.time.Instant
1313import java.util.Date
1414import java.util.UUID
1515
16+ /* *
17+ * A Kotlinx [KSerializer] for Axon Framework's [MetaData] type, supporting serialization across any format.
18+ *
19+ * This serializer converts a [MetaData] instance to a JSON-encoded [String] using a recursive conversion
20+ * of all entries into [JsonElement]s. This JSON string is then serialized using [String.serializer],
21+ * ensuring compatibility with any [kotlinx.serialization.encoding.Encoder]—including formats such as JSON, CBOR, ProtoBuf, or Avro.
22+ *
23+ * ### Supported value types
24+ * Each entry in the MetaData map must conform to one of the following:
25+ * - Primitives: [String], [Int], [Long], [Float], [Double], [Boolean]
26+ * - Temporal types: [UUID], [Date], [Instant]
27+ * - Collections: [Collection], [List], [Set]
28+ * - Arrays: [Array]
29+ * - Nested Maps: [Map] with keys convertible to [String]
30+ *
31+ * ### Limitations
32+ * - Custom types that do not fall into the above categories will throw a [SerializationException]
33+ * - Deserialized non-primitive types (like [UUID], [Instant], [Date]) are restored as [String], not their original types
34+ *
35+ * This serializer guarantees structural integrity of nested metadata (e.g. map within list within map), while remaining format-agnostic.
36+ *
37+ * @author Mateusz Nowak
38+ * @since 4.11.1
39+ */
1640object MetaDataSerializer : KSerializer<MetaData> {
1741
1842 private val json = Json { encodeDefaults = true ; ignoreUnknownKeys = true }
0 commit comments