JSON提取网址数据

时间:2019-06-19 04:21:44

标签: javascript php json

[{
    "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获取此输出?

1 个答案:

答案 0 :(得分:-1)

您可以使用Array.mapNumber

let 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);