猿问

JSON 获取 url 数据

[{

    "call_time": "0",

    "total_inc_traffic": "1363.10",

    "total_out_traffic": "88.70"

}, {

    "call_time": "1",

    "total_inc_traffic": "479.57",

    "total_out_traffic": "36.98"

}, {

    "call_time": "2",

    "total_inc_traffic": "239.57",

    "total_out_traffic": "13.43"

}, {

    "call_time": "3",

    "total_inc_traffic": "190.28",

    "total_out_traffic": "8.20"

}, {

    "call_time": "4",

    "total_inc_traffic": "223.80",

    "total_out_traffic": "0.00"

}, {

    "call_time": "5",

    "total_inc_traffic": "158.87",

    "total_out_traffic": "19.58"

}]

这是我想要将所有“total_inc_traffic”输出的输出作为的网址


{1363.10,479.57,239.57,190.28,158.87}

如何使用json获取此输出?


侃侃无极
浏览 214回答 1
1回答

慕码人8056858

您可以使用Array.map和Numberlet arr = [{ "call_time": "0", "total_inc_traffic": "1363.10", "total_out_traffic": "88.70" }, { "call_time": "1", "total_inc_traffic": "479.57", "total_out_traffic": "36.98" }, { "call_time": "2", "total_inc_traffic": "239.57", "total_out_traffic": "13.43" }, { "call_time": "3", "total_inc_traffic": "190.28", "total_out_traffic": "8.20" }, { "call_time": "4", "total_inc_traffic": "223.80", "total_out_traffic": "0.00" }, { "call_time": "5", "total_inc_traffic": "158.87", "total_out_traffic": "19.58" }];let result = arr.map(v => Number(v.total_inc_traffic));console.log(result);
随时随地看视频慕课网APP
我要回答