Javascript json值的长度?
给定数据,如:Javascript json值的长度?,javascript,jquery,json,string-length,Javascript,Jquery,Json,String Length,给定数据,如: var json = [ { "id": "A", "status": 1, "rank": 30, "score": 0.1 }, { "id": "B", "status": 1, "rank": 30, "score": 0.7 }, { "id": "C", "status": 1, "rank": 60, "score": 0.8 }, { "id": "AB", "status": 1, "rank": 160, "scor
var json = [
{ "id": "A", "status": 1, "rank": 30, "score": 0.1 },
{ "id": "B", "status": 1, "rank": 30, "score": 0.7 },
{ "id": "C", "status": 1, "rank": 60, "score": 0.8 },
{ "id": "AB", "status": 1, "rank": 160, "score": 0.6 },
{ "id": "ABC", "status": 1, "rank": 400, "score": 0.2 }
];
如何获取id的长度?
小提琴:
以下操作不起作用:
var l = (json[3].id).text().length();
console.log("l = "+ l );
使用*.lenght
var l = json[3].id.length;
console.log("length["+json[3].id+"] = "+ l );
请参阅更新小提琴链接
你想提到
length
比如length代码>非长度()代码>您问的是如何获取字符串的长度???是的。。。这是一个打字错误。
var len = json[3].id.length;
console.log("len = "+ len);
var l = (json[3].id).length