Last active
December 22, 2015 01:38
-
-
Save tdantas/6397702 to your computer and use it in GitHub Desktop.
YAML Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| %w(yaml ap).each { |dep| require dep } | |
| obj = YAML::load(DATA) | |
| puts "-" * 30 | |
| ap obj['firstName'] | |
| puts "-" * 30 | |
| ap obj | |
| puts "-" * 30 | |
| __END__ | |
| { | |
| "firstName": "Thiago", | |
| "lastName": "Dantas", | |
| "email": "[email protected]", | |
| "age": 30, | |
| "address": { | |
| "streetAddress": "Rua do Galvao", | |
| "city": "Lisbon", | |
| }, | |
| "phoneNumber": [ | |
| { | |
| "type": "home", | |
| "number": "000-000-0000" | |
| }, | |
| { | |
| "type": "mobile", | |
| "number": "999 999 999" | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ------------------------------ | |
| "Thiago" | |
| ------------------------------ | |
| { | |
| "firstName" => "Thiago", | |
| "lastName" => "Dantas", | |
| "email" => "[email protected]", | |
| "age" => 30, | |
| "address" => { | |
| "streetAddress" => "Rua do Galvao", | |
| "city" => "Lisbon" | |
| }, | |
| "phoneNumber" => [ | |
| [0] { | |
| "type" => "home", | |
| "number" => "000-000-0000" | |
| }, | |
| [1] { | |
| "type" => "mobile", | |
| "number" => "999 999 999" | |
| } | |
| ] | |
| } | |
| ------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment