2013-07-05 34 views
1

這樣的假設數據:json值的長度?

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的長度是多少?

小提琴:http://jsfiddle.net/RBSC9/


下不工作:

var l = (json[3].id).text().length(); 
console.log("l = "+ l); 
+0

你詢問如何得到一個字符串的長度??? –

+0

是...是一個錯字錯誤。 – Hugolpz

回答

1
var len = json[3].id.length; 
console.log("len = "+ len);