-
-
Notifications
You must be signed in to change notification settings - Fork 148
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 to use long keys in YAML #334
Conversation
It seems to me like this should be configurable as a number. But not sure if it's worth the effort for adding the API for that, and if it doesn't compromise the "hide snakeyaml" idea. |
In my case, I have yaml-generated keys that can be very long and cause a lot of output with In the first place, I have defined this feature as a toggle so it remains simple to use it. As you said, it can be a number. But I am not sure this is really worth it. Maybe some users really know the max lengths of their keys. If this is the main case, it will be good to use a number here. I have not found much feedback about this, do we have some? |
This sounds like a good improvement. I have just one significant concern here: backwards-compatibility. Since code as-is would have hard dependency for the new method, it would strictly require use of a specific minimum version. This may not sound like a big deal but with transitive dependency challenges chances are that it would make some upgrades more difficult. So: which version of SnakeYAML was this added in? Specifically I am worried about failure during runtime for cases where configuration method is NOT called -- if user does try to enable long-string support it's fair to assume version is new. This can be tested manually with older SnakeYAML version; not sure if there's a way (maybe using Maven profiles?) to add an automated test (integration test?) But at any rate, unless this setting is available in relatively old version (Jackson 2.12 depends on |
@@ -310,6 +320,10 @@ protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, | |||
if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) { | |||
opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); | |||
} | |||
|
|||
if (Feature.USE_LONG_KEYS.enabledIn(_formatFeatures)) { | |||
opt.setMaxSimpleKeyLength(1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the setting that would need to be encapsulated in a separate class, with a method that gets opt
passed in, sets the maximum length. Since that class is only loaded when method called (first "active use") it is possible
to avoid failure when YAMLGenerator
class itself is initialized.
Class loading exception should trigger throwing of exception that suggests too old SnakeYAML dependency.
According to this ticket. This feature has been available since version 1.24 of SnakeYaml. I will check on adding a wrapper to make it less error-prone as you explain it. 😄 |
@ShauniArima Actually if it's that old a fix, never mind -- Jackson 2.10.0 already had snakeyaml 1.24 that as the dependency version. I am not as worried in that case, wrt 2.14.0. So the one and only thing I'd need (unless already done, apologies if I forgot) is the CLA, from: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf and the usual way is to print it, fill & sign, scan/photo, email to |
I have filled and signed the CLA. You will receive a mail soon. 😉 |
Adding a new feature (
USE_LONG_KEYS
) that setmaxSimpleKeyLength
to 1024 (the maximum available length). It is set to false by default to keep the default behaviour of SnakeYAML.It answer this issue : #244.