Using the JSON class:
Importing a file:
require "json"
file = File.open "/path/to/your/file.json"
data = JSON.load file
Optionally, you can close it now:
file.close
The file looks like this:
{
"title": "Facebook",
"url": "https://www.facebook.com",
"posts": [
"lemon-car",
"dead-memes"
]
}
The file is now able to be read like this:
data["title"]
=> "Facebook"
data.keys
=> ["title", "url", "posts"]
data['posts']
=> ["lemon-car", "dead-memes"]
data["url"]
=> "https://www.facebook.com"
Hope this helped!