0
私は、ネストの解除、再グループ化、状態の再ネストが必要な次のJSONオブジェクトを持っています。私は、何らかのfor-loopとgroup by operationが必要であることを理解しています。Javascript - JSON - ネストとグループ化
[
{
"Date": "2000-01-01T08:00:00.000Z",
"Florida": "4626",
"New York": "210",
"Pennsylvania": "1500",
"Virginia": "9",
"West Virginia": "1400",
"Illinois": "12206",
"Indiana": "2098",
"Kansas": "34463",
"Kentucky": "3465",
"Michigan": "7907",
"Missouri": "94",
"Nebraska": "2957",
"North Dakota": "32719",
"Ohio": "6575",
"Oklahoma": "69976",
"South Dakota": "1170",
"Tennessee": "346",
"Alabama": "10457",
"Arkansas": "7154",
"Louisiana": "105425",
"Mississippi": "19844",
"New Mexico": "67198",
"Texas": "443397",
"Colorado": "18481",
"Montana": "15428",
"Utah": "15636",
"Wyoming": "60726",
"Alaska": "355199",
"Alaska South": "10590",
"Arizona": "59",
"California": "271132",
"Nevada": "621",
"": ""
},
{
"Date": "2001-01-01T08:00:00.000Z",
"Florida": "4426",
"New York": "166",
"Pennsylvania": "1620",
"Virginia": "11",
"West Virginia": "1226",
"Illinois": "10092",
"Indiana": "2022",
"Kansas": "33942",
"Kentucky": "2969",
"Michigan": "7375",
"Missouri": "91",
"Nebraska": "2922",
"North Dakota": "31691",
"Ohio": "6051",
"Oklahoma": "68531",
"South Dakota": "1255",
"Tennessee": "351",
"Alabama": "9334",
"Arkansas": "7592",
"Louisiana": "104610",
"Mississippi": "19528",
"New Mexico": "68001",
"Texas": "424297",
"Colorado": "16520",
"Montana": "15920",
"Utah": "15252",
"Wyoming": "57433",
"Alaska": "351411",
"Alaska South": "11500",
"Arizona": "59",
"California": "260663",
"Nevada": "572",
"": ""
},
{
"Date": "2002-01-01T08:00:00.000Z",
"Florida": "3634",
"New York": "164",
"Pennsylvania": "2324",
"Virginia": "25",
"West Virginia": "1456",
"Illinois": "11100",
"Indiana": "1962",
"Kansas": "33380",
"Kentucky": "2721",
"Michigan": "7218",
"Missouri": "95",
"Nebraska": "2782",
"North Dakota": "30803",
"Ohio": "5631",
"Oklahoma": "66421",
"South Dakota": "1214",
"Tennessee": "275",
"Alabama": "8636",
"Arkansas": "7252",
"Louisiana": "93321",
"Mississippi": "19371",
"New Mexico": "67562",
"Texas": "405776",
"Colorado": "20522",
"Montana": "16990",
"Utah": "13771",
"Wyoming": "54801",
"Alaska": "359382",
"Alaska South": "11303",
"Arizona": "63",
"California": "257898",
"Nevada": "553",
"": ""
}
]
私は状態のキーは状態名と生産の鍵は何年と、その年の生産と辞書の配列である以下のフォーマットに上記を処理したいと思います。
[
{
"state": "California",
"production": [
{
"Date": "2000-01-01T08:00:00.000Z",
"production": 1000
},
{
"Date": "2001-01-01T08:00:00.000Z",
"production": 2000
}
]
},
{
"state": "New York",
"production": [
{
"Date": "2000-01-01T08:00:00.000Z",
"production": 4000
},
{
"Date": "2001-01-01T08:00:00.000Z",
"production": 5000
}
]
}
]
上記のフォーマットを達成するために実行する必要がある操作を教えてください。ありがとうございました!
生産値は、元のJSONから来る... "フロリダ": "4626"、 "ニューヨーク": "210"、 "ペンシルベニア州": "1500" ... – verkter