Editing JSON Array contents in Ruby
问题 My JSON array is structured like this: {"data":[{"Chris":[{"long":10,"lat":19}]},{"Scott":[{"long":9,"lat":18}]}]} In the ruby program, I am wanting to be able to edit the lat and long values for the names. But I am not quite sure how to do so. sections.each do |user_coords| user_coords.each do |user, coords| if user == Usrname then #Change lat and long value for Usrname end end end How can this be done? 回答1: This is how to access individual elements in your JSON: require 'json' foo = JSON['{