I'm trying to get daily values from google rate exchange API (http://rate-exchange.appspot.com/currency?from=USD&to=EUR) and write the values to a JSON file. What I have so far is:
quote = agent.get("http://rate-exchange.appspot.com/currency?from=USD&to=EUR").body
parsed = JSON.parse(quote)
stored = {:date => Time.now, :rate => parsed['rate']}
File.open("ruby_test.json", "w") { |f| f.write(JSON.pretty_generate(stored)) }
But this will overwrite my json file everytime I run it, the error is the way I am creating the ruby hash or the way I'm writing the json file?