js如何获取json数组的长度
1个回答
展开全部
JSON转成对象直接拿呗。
var str = '{"dpxid":"DP_144226","count":"5","timevalue":[{"time":"1464273902796","value":"27.0"},{"time":"1464273904796","value":"28.0"},{"time":"1464273906796","value":"27.0"},{"time":"1464273908796","value":"26.0"},{"time":"1464274144796","value":"20.0"}],"error":"OK" }';
console.log("JSON length: " + str.length);
var obj = JSON.parse(str);
console.log("count is: " + obj.count);
var str = '{"dpxid":"DP_144226","count":"5","timevalue":[{"time":"1464273902796","value":"27.0"},{"time":"1464273904796","value":"28.0"},{"time":"1464273906796","value":"27.0"},{"time":"1464273908796","value":"26.0"},{"time":"1464274144796","value":"20.0"}],"error":"OK" }';
console.log("JSON length: " + str.length);
var obj = JSON.parse(str);
console.log("count is: " + obj.count);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询