json5k icon indicating copy to clipboard operation
json5k copied to clipboard

Ignore unkown keys

Open elliotnash opened this issue 2 years ago • 2 comments

Is there a way to ignore unknown keys in json5k (kotlinx equivalent of Json { ignoreUnknownKeys = true }?

elliotnash avatar Feb 26 '23 00:02 elliotnash

At the time being, I am afraid this is not possible.

As part of #2, I plan to add a more flexible interface between the parser and the kotlinx.serialization integration. When this is available, implementing an ignoreUnknownKeys option will be straightforward.

xn32 avatar Mar 03 '23 07:03 xn32

Maybe this should work?

val json = Json5.decodeFromString<JsonElement>(text)
val obj = Json { ignoreUnknownKeys = true }.decodeFromJsonElement<Obj>(json)

ileasile avatar May 08 '23 11:05 ileasile