我有一个图表:
而我
"city_id":[
"1",131,
"2",96,
"3",11,
"4",10,
"7",8,
"6",6,
"15",5,
"10",4,
"34",4,
"36",3,
"59",3,
"71",1]},
引号中是city_id,右侧是该城市的作业计数
我想把它们处理成这样的散列
{:region_1=>
{["city_name", "slug"]=>jobs count,
["city_name", "slug"]=>jobs count,
["city_name", "slug"]=>jobs count},
:region_2=>
{["city_name", "slug"]=>jobs count,
["city_name", "slug"]=>jobs count,
["city_name", "slug"]=>jobs count},
...
}
1条答案
按热度按时间vjrehmav1#
这不是最干净的方法,但它可以工作:
这会使你的奇怪的数组列表变成一个散列: