4 ms·
When I read this, I didn't believe it. I needed to prove this to myself! I've seen and used YAML files for configurations in many places and I've always found
by thunderbong 6y ago
When I read this, I didn't believe it. I needed to prove this to myself!
I've seen and used YAML files for configurations in many places and I've always found editing YAML files by hand too much of a pain. It's very easy to miss a space and screw everything up. However, writing JSON directly into a plain text file is totally easy.
So, I created a normal text file named 'array_of_objects.json' like this -
[
{
"first": "one"
},
{
"second": "two"
}
]
And then I wrote a ruby program to read it -
require 'json'
require 'yaml'
array_of_objects = YAML.load_file 'array_of_objects.json'
p array_of_objects
And I see the output as -
[{"first"=>"one"}, {"second"=>"two"}]
I still can't get over it. I'm thinking of the countless hours wasted!!
Thank you so much.