Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on YAML

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

General Tips and Traps

  1. YAML is much better alternative to JSON. TOML is another good alternative to YAML.

Ranges in YAML

https://stackoverflow.com/questions/48199439/use-range-with-stepsize-in-yaml-file

YAML for Rust

Please …

Commonly Used File Formats for Configuration

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. JSON is more commonly used for application data and configurations
    which are not intended to be read by human directly.

  2. TOML and YAML are more popular for application configurations which are …

Parse YAML in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comments

  1. The serde_yaml crate is the best tool for parsing YAML in Rust.

Parsing YAML in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. PyYAML (YAML 1.1 currently) and ruamel.yaml (YAML 1.2) are 2 Python libraries for parsing YAML. PyYAML is more widely used.

  2. PyYAML is preferred over json for serialization and deserialization for multiple reasons.

    • PyYAML is a superset of json.

Use SnakeYaml in Scala

SnakeYAML

moultingyaml: Scala wrapper for SnakeYAML

Comment

If the input YAML doc has multiple formats, you can first load it as an Object and then use Object.isInstanceOf to check its type and use Object.asInstanceOf[SomeType] to cast it to the right type.