Kotlinx Object Model
A read-only JsonModel over Kotlin objects, through their kotlinx.serialization serializers.
The model reads your objects directly: the JSON view of a node is the JSON that Json.encodeToJsonElement gives for it with the same Json instance, but the model does not encode a whole tree. When a query visits a node, the serializer of the node writes its direct children into a capturing encoder. A child object is kept as its value and its serializer, and it is read only when a query visits it.
val model = KotlinxObjectModel(Json)
val nodes = JsonPathEvaluator.standard().evaluate(query, model.node(order, Order.serializer()), model)
val line = nodes.first().value().value // your own objectThe view follows the configuration of the Json instance: encodeDefaults, explicitNulls, the naming strategy, enums, value classes, and unsigned numbers. For a polymorphic or contextual value, a map with structured keys, a serializer that writes more than one level, and the class discriminator mode ClassDiscriminatorMode.ALL_JSON_OBJECTS, the model reads that part through Json.encodeToJsonElement, so the view is always the JSON of the instance.
The model is well-formed for values that json can encode. For a value that json cannot encode, for example Double.NaN without allowSpecialFloatingPointValues, the view is not defined, and a read can throw the exception of json.
The model is read-only: Kotlin objects are immutable. To patch an object, encode it, use JsonPatch.applyToCopy with KotlinxJsonModel, and decode the result.
Properties
Functions
The members of a shape are a map, so they cannot hold duplicate names.