require 'json'
badges = File.open("badges.txt", "r")
doc = ""
badges.each do |line|
doc << line
end
badges.close
puts JSON.parse(doc)
Dados JSON para badges.txt
{
"badges" :
{
"badge1" : {
"name" : "Name of Badge1",
"subject" : "Subject of Badge1 "
},
"badge2" : {
"name" : "Name of Badge2",
"subject" : "Subject of Badge2 "
}
}
}