sjakobi
sjakobi

Reputation: 3606

How do I convert YAML 1.1 to YAML 1.2?

I want to feed YAML 1.1 documents to a parser that (largely) complies with YAML 1.2. How can I can I convert my input so it is interpreted correctly by the parser?

A CLI tool would be helpful, or a bit of code that could be turned into a CLI tool.

Upvotes: 1

Views: 733

Answers (1)

tinita
tinita

Reputation: 4346

It depends if this is more about YAML syntax or the Schema. Maybe you should clarify what exact problem you have. I will guess here.

If it's about the syntax: I think there are not much YAML processors out there that differentiate between the YAML 1.1 and 1.2 syntax. Either they are older and implement 1.1, or they are newer and were written for 1.2. The differences between the versions regarding syntax are not huge, and there are probably not so many use cases in real world, where this is important.


If it's about the schema, you probably want to convert things like yes to true.

I recently started a tool called yaml-schema-convert. You can find it here: https://github.com/perlpunk/yamlpp-tools

It can do the conversion for you. However, it is not complete. For example, it doesn't recognize timestamps.

It's written in perl, and since the module (YAML::PP) is not yet in many distributions, you probably need to install it from CPAN.

On debian this would be:

apt-get install cpanminus
cpanm YAML::PP
cpanm Getopt::Long::Descriptive
cd yamlpp-tools
perl bin/yamlpp-schema-convert < file.yaml

Would be glad for feedback, if it works.

Upvotes: 1

Related Questions