How to parse YAML file in ruby

Dhinesh Kumar's Blog

Parsing YAML FILE

YAML

YAML is a flexible, human readable file format. It is  easier to read (by humans) than JSON.

YAML File

– Name: Don
   Age: 35
  City: YYY
– Name: Peter
  Age: 30
  City: XXX

Ruby Code

require 'yaml'file_content= YAML.load_file("Name of the file")p file_content

Output

 [{"Name"=>"Don", "Age"=>35, "City"=>"YYY"}, {"Name"=>"Peter", "Age"=>30, "City"=>"XXX"}]

View original post

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: