hardwired
12/26/2014 - 7:52 AM

item json sort by name

item json sort by name

require 'json'

file = open('item.json').read

hash = JSON.parser.new(file).parse()
item = hash['data']

sorted = item.sort_by {|key, val| val['name']}
hash['data'] = sorted
File.write 'item_sorted.json', hash.to_json