JKid is a small pure Kotlin library that converts Kotlin objects to JSON and reconstructs objects from JSON. Reflection inspects arbitrary object properties at runtime, while annotations customize serialization and deserialization behavior. section 12.0 section 12.1.3
Serialize and deserialize a Person
Define a Kotlin data class, pass an instance to serialize, and receive JSON such as {"age": 29, "name": "Alice"}. Passing JSON to deserialize<Person> reconstructs Person(name=Alice, age=29). section 12.1.3
data class Person(val name: String, val age: Int)
fun main() {
val person = Person("Alice", 29)
println(serialize(person))
// {"age": 29, "name": "Alice"}
}
A compact runnable example shows the basic serialization path from a Kotlin Person object to textual JSON. section 12.1.3
Annotations adapt the JSON representation without changing the Kotlin model:
- @JsonName("alias") maps the firstName property to the JSON field alias during both serialization and deserialization. section 12.1.3
- @JsonExclude omits the age property from JSON; a nullable property with a default value illustrates the customized model. section 12.1.3
