kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Are there any plan add on-the-fly JSON Schema validation?

Open iseki0 opened this issue 1 year ago • 4 comments

What is your use-case and why do you need this feature? For the JSON format, do validation during deserialization is absolutely effecienct. Are there any plan or suggestion to complete it?

iseki0 avatar Jun 21 '24 03:06 iseki0

Can you elaborate, please? We do not have any integrations with Json Schema for now, any kind of advanced validation should happen in init {} block of serializable classes

sandwwraith avatar Jun 21 '24 18:06 sandwwraith

Thank you, I means if we can add some feature for it, compose the decoding and validation process, it will be more effeciency. Such as we needn't tokenize the input again.

In that case, JSON schema is a good choice, because it's standardized and widely supported.

iseki0 avatar Jun 24 '24 03:06 iseki0

I still don't get how it should look like. And what do you mean by 'needn't tokenize the input again.'? If you have your validation in init{}, it happens after the class is deserialized as usual.

sandwwraith avatar Jun 24 '24 12:06 sandwwraith

I understand we can do validation during class init, but here's a problem that it's not standardized and it can't cross platform.(I means programming language.).

iseki0 avatar Jun 24 '24 17:06 iseki0

No plans for now, can be discussed as a part of #1115

sandwwraith avatar Nov 27 '24 16:11 sandwwraith