JsonToKotlinClass icon indicating copy to clipboard operation
JsonToKotlinClass copied to clipboard

For `null` properties, use JsonNode/JsonElement instead of Any

Open jmfayard opened this issue 3 years ago • 1 comments

Bonjour,

your plugin is fantastic, what a waste of time it seems now to have written the data classes manually!

I have a request:

If my json contains a null like

{
"started_at": "sdfqsdds",
"closed_at" : null
}

the plugin is currently translating to the Any? type, which gives me a runtime/compile error (don't remember).

I would rather have those types being used, depending on my serialization library:

val jackson: com.fasterxml.jackson.databind.JsonNode? = TODO()
val kotlinx : kotlinx.serialization.json.JsonElement? = TODO()

jmfayard avatar Aug 11 '22 06:08 jmfayard

Good advice! Will fix it next version,thanks

wuseal avatar Aug 13 '22 19:08 wuseal