Skip to content

Kotlin Klaxon cannot deserialize empty object map values as JsonObject #2881

Description

@schani

Summary

The Kotlin/Klaxon renderer can generate map values as JsonObject for empty object shapes, but Klaxon fails to deserialize {} into JsonObject in that position.

Reproduction

This was found while adding the regression fixture in #2877:

{
  "mission_specs": {
    "1": { "objectives": { "2": { "rewards": { "3": {}, "5": {} } } } },
    "4": { "objectives": { "6": { "rewards": {} } } }
  }
}

The generated Kotlin contains:

val rewards: Map<String, Reward>
typealias Reward = JsonObject

Running the Kotlin/Klaxon fixture fails with:

KlaxonException: Couldn't find a suitable constructor for class JsonObject to initialize with {}

Expected behavior

The generated Kotlin/Klaxon code should deserialize empty object values in maps successfully, or represent that shape in a way Klaxon can handle.

Notes

#2877 is skipping its new fixture for Kotlin/Klaxon so the unrelated core regression fix can pass CI. Kotlin-Jackson did not hit this failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions