gpt4 book ai didi

javascript - 访问 json 对象的第二级

转载 作者:行者123 更新时间:2023-11-30 07:55:26 25 4
gpt4 key购买 nike

<分区>

我有一个如下所示的数据对象:

[
{
"key": "K1204",
"values": [
{
"key": "Both",
"values": [
{
"key": 1420070400000,
"values": 27927.7349421797
},
{
"key": 1422748800000,
"values": 27927.7349421797
},
{
"key": 1425168000000,
"values": 27927.7349421797
},
{
"key": 1427846400000,
"values": 27927.7349421797
},
{
"key": 1430438400000,
"values": 27927.7349421797
},
{
"key": 1433116800000,
"values": 27927.7349421797
},
{
"key": 1435708800000,
"values": 27927.7349421797
},
{
"key": 1438387200000,
"values": 27927.734942179697
},
{
"key": 1441065600000,
"values": 27927.7349421797
},
{
"key": 1443657600000,
"values": 27927.7349421797
},
{
"key": 1446336000000,
"values": 36929.2001421797
},
{
"key": 1448928000000,
"values": 36929.2001421797
},
{
"key": 1451606400000,
"values": 36929.2001421797
},
{
"key": 1454284800000,
"values": 36929.200142179696
},
{
"key": 1456790400000,
"values": 36929.2001421797
},
{
"key": 1459468800000,
"values": 36929.200142179696
},
{
"key": 1462060800000,
"values": 36929.200142179696
},
{
"key": 1464739200000,
"values": 36929.200142179696
},
{
"key": 1467331200000,
"values": 36929.2001421797
},
{
"key": 1470009600000,
"values": 36929.2001421797
},
{
"key": 1472688000000,
"values": 36929.2001421797
},
{
"key": 1475280000000,
"values": 36929.2001421797
},
{
"key": 1477958400000,
"values": 36929.200142179696
},
{
"key": 1480550400000,
"values": 36929.200142179696
},
{
"key": 1483228800000,
"values": 36929.200142179696
},
{
"key": 1485907200000,
"values": 36929.200142179696
},
{
"key": 1488326400000,
"values": 36929.200142179696
}
]
}
]
}
]

我要做的是让它看起来像这样:

[
{
"key": "Both",
"values": [
{
"key": 1420070400000,
"values": 27927.7349421797
},
{
"key": 1422748800000,
"values": 27927.7349421797
},
{
"key": 1425168000000,
"values": 27927.7349421797
},
{
"key": 1427846400000,
"values": 27927.7349421797
},
{
"key": 1430438400000,
"values": 27927.7349421797
},
{
"key": 1433116800000,
"values": 27927.7349421797
},
{
"key": 1435708800000,
"values": 27927.7349421797
},
{
"key": 1438387200000,
"values": 27927.734942179697
},
{
"key": 1441065600000,
"values": 27927.7349421797
},
{
"key": 1443657600000,
"values": 27927.7349421797
},
{
"key": 1446336000000,
"values": 36929.2001421797
},
{
"key": 1448928000000,
"values": 36929.2001421797
},
{
"key": 1451606400000,
"values": 36929.2001421797
},
{
"key": 1454284800000,
"values": 36929.200142179696
},
{
"key": 1456790400000,
"values": 36929.2001421797
},
{
"key": 1459468800000,
"values": 36929.200142179696
},
{
"key": 1462060800000,
"values": 36929.200142179696
},
{
"key": 1464739200000,
"values": 36929.200142179696
},
{
"key": 1467331200000,
"values": 36929.2001421797
},
{
"key": 1470009600000,
"values": 36929.2001421797
},
{
"key": 1472688000000,
"values": 36929.2001421797
},
{
"key": 1475280000000,
"values": 36929.2001421797
},
{
"key": 1477958400000,
"values": 36929.200142179696
},
{
"key": 1480550400000,
"values": 36929.200142179696
},
{
"key": 1483228800000,
"values": 36929.200142179696
},
{
"key": 1485907200000,
"values": 36929.200142179696
},
{
"key": 1488326400000,
"values": 36929.200142179696
}
]
}
]

我试过这个:

var data_costByScn2 = data3.values

console.log("data3val: ", data_costByScn2)

但它返回未定义...我如何让它返回 json 对象中的下一个级别?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com