尝试合并这些对象,以使每年都是一个对象,其中包括那些年份的月份。
从此:
[{"Year":"2019","02":"3.249"},{"Year":"2019","01":"3.228"},{"12":"3.340","Year":"2018"},{"11":"3.474","Year":"2018"},{"10":"3.516","Year":"2018"},{"Year":"2018","09":"3.409"},
{"Year":"2017","04":"2.767"},{"Year":"2017","03":"2.751"},{"Year":"2017","02":"2.768"},{"12":"2.647","Year":"2016"},{"11":"2.562","Year":"2016"},{"10":"2.554","Year":"2016"},{"Year":"2016","09":"2.492"},{"Year":"2016","08":"2.442"},{"Year":"2016","07":"2.510"}]
对此:
[{"Year":"2019","02":"3.249","01":"3.228"},
{"12":"3.340","11":"3.474","10":"3.516","Year":"2018","09":"3.409"},
{"Year":"2017","04":"2.767","03":"2.751","02":"2.768"},
{"10":"2.554","Year":"2016","09":"2.492","08":"2.442","07":"2.510"}]
然后我想从合并对象中为每个对象提取Year,并将结果用作循环变量。