asia_teachers = JSON.parse(File.read('asia_teachers.json')) asia_academies = JSON.parse(File.read('asia_academies.json')) asia_depart_teachers = asia_academies.map do |academy, departs_info| [academy, departs_info.map{|depart_name, url| [depart_name, asia_teachers[url].to_a] }.to_h ] end.to_h File.open('asia_depart_teachers.json', 'w+'){|f| f.write(asia_depart_teachers.to_json)}