Skip to content
uencoder

YAML Ruby Binding

YAML Ruby bindings are the parsing API for Ruby provided by Psych (the Ruby standard library), mapping YAML to Ruby objects.

Purpose

To read and write YAML in Ruby applications, mapping YAML to Hash/Array/Object and supporting Ruby object serialization.

Mechanism

YAML.load(yaml_str) returns a Ruby object and YAML.dump(obj) returns a YAML string. Psych is the default YAML engine since Ruby 2.0, supporting YAML 1.1. Use safe_load to guard against object injection.

Use cases

  • Rails configuration
  • Ruby object serialization
  • Gem metadata

Related tools

References