0

I want to do this in ruby.

Say I have an example.json file that looks like

{
   "name" : "My name is - "
}

and I want to update that to

{
   "name" : "My name is - Chris"
}

I know to do this

require 'json'
json = JSON.parse('example.json')
name = json['name'] + ' Chris'

Now how I write name back into example.json file and save the file, simply like this?

json['name'] = name
Chris F
  • 14,337
  • 30
  • 94
  • 192
  • 4
    Have you at least tried the last bit of your question? – akalikin Aug 19 '15 at 16:16
  • 1
    Author, did you even bother googling "ruby json"? Or testing the code you provided? Go read http://devdocs.io/ruby/json - If this doesn't answer all your questions I'll gladly help or provide examples. – mhutter Aug 19 '15 at 16:50

0 Answers0