Description
At the moment, a field name with a length of 128 characters or longer results in Jackson's YAML generator producing YAML like this:
---
? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
: anything
Using 1 less character in the field name results in the usual YAML syntax.
---
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: anything
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:
public int getMaxSimpleKeyLength() {
return maxSimpleKeyLength;
}
/**
* 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 '?'
*/
public void setMaxSimpleKeyLength(int maxSimpleKeyLength) {
if(maxSimpleKeyLength > 1024) {
throw new YAMLException("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.
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. Thanks