Does spring boot 2.1.x support yaml 1.2 specification?

If not, is it possible to use yaml 1.2 + snakeyaml-engine for the spring boot application.yml support?

I have a requirement to add some json content within application.yml to use as is at runtime.

Comment From: wilkinsona

Does spring boot 2.1.x support yaml 1.2 specification?

No. Spring Boot uses org.yaml:snakeyaml which does not support YAML 1.2.

If not, is it possible to use yaml 1.2 + snakeyaml-engine for the spring boot application.yml support?

Not at the moment, no. snakeyaml-engine has a completely different API so would have to be supported separately.

I have a requirement to add some json content within application.yml to use as is at runtime.

This sounds like it would be YAML-specific and would not work well with application.properties, command line arguments, system properties, etc. Generally speaking we recommend that a configuration property is used to specify a file which contains the more complex data. This files then read at runtime and its content used as needed. This is what Boot itself does for configuring SSL trust and key stores, for example.

Does that not meet your needs?

Comment From: KiranMohan

Generally speaking we recommend that a configuration property is used to specify a file which contains the more complex data.

This is what I would do now until Spring supports yaml 1.2 for application.yml

Does that not meet your needs? Yes. I was evaluating all available options.

Comment From: asomov

@wilkinsona feel free to ping me if you need support when you decided to go to YAML 1.2 with SnakeYAML Engine. I have already some preparations.

Comment From: gy-mate

Not at the moment, no. snakeyaml-engine has a completely different API so would have to be supported separately.

@wilkinsona @philwebb I would recommend supporting it. Rookie mistake on my side, but I've spent several hours trying to figure out why a @Value injection assigned a wrong value (1067 instead of 00002053) to a String field. Turns out, it parsed 00002053 as an octal number, then casted that number in decimal (1067) to a String.

YAML 1.2 fixed this by requiring Oo at the beginning of octal integers.

I know, if I want to use the number in the YAML as a String, I should've put it between apostrophes, but this whole thing could've been avoided with YAML 1.2.

Related questions: https://stackoverflow.com/questions/42828311/value-from-application-yml-returns-wrong-value https://stackoverflow.com/questions/56558270/does-spring-boot-2-1-x-support-yaml-1-2-specification

Comment From: asomov

@gy-mate dropping octal numbers is not a challenge (comparing to how Spring is already using SnakeYAML). No need to change SnakeYAML - it has a concept of Resolver which should ignore octal numbers. I can help to implement it. Examples of usage of Resolver are in the tests of SnakeYAML