Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Ignore unkown keys #7

Open
elliotnash opened this issue Feb 26, 2023 · 2 comments
Open

Ignore unkown keys #7

elliotnash opened this issue Feb 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@elliotnash
Copy link

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

@xn32
Copy link
Owner

xn32 commented Mar 3, 2023

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 xn32 added the enhancement New feature or request label Mar 12, 2023
@ileasile
Copy link

ileasile commented May 8, 2023

Maybe this should work?

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants