Parse and Generate JSON in Ruby
RubyParse a JSON string into a Hash and convert back with the json stdlib.
require 'json'
raw = '{"name":"chris","tags":["ruby","rails"]}'
data = JSON.parse(raw)
data['tags'] << 'sinatra'
puts JSON.pretty_generate(data)