Last Updated: February 25, 2016
·
309
· jkcpr

# JSON parsed by Ruby

require 'json'

badges = File.open("badges.txt", "r")

doc = ""
badges.each do |line|
  doc << line
end
badges.close

puts JSON.parse(doc)

JSON data for badges.txt

{ 
"badges" : 
  {
    "badge1" : {
      "name"  :  "Name of Badge1",
      "subject"  :  "Subject of Badge1 "
    },
    "badge2" : {
      "name"  :  "Name of Badge2",
      "subject"  :  "Subject of Badge2 "
    }
  }
}