为了账号安全,请及时绑定邮箱和手机立即绑定

JSON 获取 url 数据

JSON 获取 url 数据

PHP
侃侃无极 2021-08-28 10:53:11
[{    "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 回答

?
慕码人8056858

TA贡献1803条经验 获得超6个赞

您可以使用Array.map和Number


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


查看完整回答
反对 回复 2021-08-28
  • 1 回答
  • 0 关注
  • 213 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信