You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently the two YAML styles are called simple keys and complex keys. SnakeYAML provides an option in its DumperOptions to change the max field name length at which SnakeYAML will switch from a) using the simple key style to b) using the complex key style. Here it is:
publicintgetMaxSimpleKeyLength() {
returnmaxSimpleKeyLength;
}
/** * Define max key length to use simple key (without '?') * More info https://yaml.org/spec/1.1/#id934537 * @param maxSimpleKeyLength - the limit after which the key gets explicit key indicator '?' */publicvoidsetMaxSimpleKeyLength(intmaxSimpleKeyLength) {
if(maxSimpleKeyLength > 1024) {
thrownewYAMLException("The simple key must not span more than 1024 stream characters. See https://yaml.org/spec/1.1/#id934537");
}
this.maxSimpleKeyLength = maxSimpleKeyLength;
}
Please could Jackson's YAML lib provide a YAML feature for using a higher value for maxSimpleKeyLength. E.g. a LONG_SIMPLE_KEYS feature that sets maxSimpleKeyLength to something like 1024.
Sounds like a good idea to offer something that allows configuring snakeyaml options without exposing snakeyaml types. Would definitely accept & help with PR, not sure I have time to work on this at this point myself.
cowtowncoder
changed the title
Provide a way to influence SnakeYAML's maxSimpleKeyLength setting
Add YAMLGenerator.Feature.ALLOW_LONG_KEYS to allow writing keys longer than 128 characters (default)
Sep 14, 2022
At the moment, a field name with a length of 128 characters or longer results in Jackson's YAML generator producing YAML like this:
Using 1 less character in the field name results in the usual YAML syntax.
Apparently the two YAML styles are called
simple keys
andcomplex keys
. SnakeYAML provides an option in itsDumperOptions
to change the max field name length at which SnakeYAML will switch from a) using the simple key style to b) using the complex key style. Here it is:https://github.com/asomov/snakeyaml/blob/88c727ce266533c1db50ac24fbd3a3f33f7fe5a0/src/main/java/org/yaml/snakeyaml/DumperOptions.java#L449-L463
Please could Jackson's YAML lib provide a
YAML feature
for using a higher value for maxSimpleKeyLength. E.g. a LONG_SIMPLE_KEYS feature that sets maxSimpleKeyLength to something like 1024.See https://bitbucket.org/asomov/snakeyaml/issues/431/increase-simple-key-length-to-1024-stream for details of what the
DumperOptions
setting was added to SnakeYAML. That issue mentions that a code change to Jackson's YAML lib would be needed to take advantage of the new setting when using Jackson. ThanksThe text was updated successfully, but these errors were encountered: