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

Yaml keys starting with number are being double quoted when mapper.writeValue() #447

Open
champi52 opened this issue Dec 7, 2023 · 1 comment
Labels
yaml Issue related to YAML format backend

Comments

@champi52
Copy link

champi52 commented Dec 7, 2023

I am writing a YAML file with mapper.writeValue() but the keys that start with a number are being double quoted even if the original key doesn't have the quotes.
I understand that the double quotes are being added because mapper want to avoid YAML to consider a String as a number, but it would be better for me to avoid the quotes.
I've tried with enable(YAMLGenerator.Feature.MINIMIZE_QUOTES)) but not helping with this issue.

Example:
//original key -> after writeValue()
6712dd2a-2695-49cb-89a8-9b5592951522: -> "6712dd2a-2695-49cb-89a8-9b5592951522":

@cowtowncoder cowtowncoder added the yaml Issue related to YAML format backend label Dec 8, 2023
@cowtowncoder
Copy link
Member

I think this is due to JsonGenerator.writeFieldName() taking String and Jackson's default key deserializers thereby having to write things as Strings. One exception there is is that JsonGenerator.writeFieldId(long) exists so actual integer number keys can be written as such, as long as backend allows that.
But same does not exist for other key types unfortunately.

So I am not sure this is something that can be changed the way things are; would require some new support by JsonGenerator (which despite name is just generator API for all formats, base type for YAMLGenerator).

But I will leave this open just in case someone has good ideas of how to possibly allow option to keep out the quotes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
yaml Issue related to YAML format backend
Projects
None yet
Development

No branches or pull requests

2 participants