Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non strict parsing #5

Closed
fvasco opened this issue Aug 13, 2019 · 5 comments
Closed

Allow non strict parsing #5

fvasco opened this issue Aug 13, 2019 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@fvasco
Copy link

fvasco commented Aug 13, 2019

Please implement a non strict Yaml parser, similar to Json.strictMode, to ignore unmapped keys.

Error on version 0.11.0:

com.charleskorn.kaml.UnknownPropertyException: Unknown property 'z'. Known properties are: a, b, c
        at com.charleskorn.kaml.YamlMapInput.throwUnknownProperty(YamlInput.kt:211)
        at com.charleskorn.kaml.YamlMapInput.decodeElementIndexForObject(YamlInput.kt:174)
        at com.charleskorn.kaml.YamlMapInput.decodeElementIndex(YamlInput.kt:159)
...
        at kotlinx.serialization.Decoder$DefaultImpls.decodeSerializableValue(Coders.kt:113)
        at kotlinx.serialization.ElementValueDecoder.decodeSerializableValue(ElementWise.kt:91)
        at kotlinx.serialization.CoreKt.decode(Core.kt:79)
        at com.charleskorn.kaml.Yaml.parse(Yaml.kt:40)
@charleskorn
Copy link
Owner

Hi @fvasco, thanks for the suggestion! I don't have a lot of capacity for this at the moment, but I will take a look when I get a chance.

If you'd be interested in submitting a PR to add this, I don't think it would be a big change and I'd be happy to provide feedback and suggestions as you go.

@charleskorn charleskorn added enhancement New feature or request good first issue Good for newcomers labels Aug 13, 2019
@charleskorn
Copy link
Owner

I found myself with some spare time so I've added this in and it'll be part of the next release - let me know if you have any feedback on the implementation!

@fvasco
Copy link
Author

fvasco commented Aug 14, 2019

Sure,
thank you!

@DanySK
Copy link

DanySK commented Sep 20, 2020

Is this implemented? How to use it?

@charleskorn
Copy link
Owner

Hi @DanySK, yes, this is implemented.

To enable strict mode, use the default settings (or set YamlConfiguration.strictMode to true).

To disable strict mode, set YamlConfiguration.strictMode to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants