gpt4 book ai didi

javascript - json值的长度?

转载 作者:行者123 更新时间:2023-11-30 13:00:37 26 4
gpt4 key购买 nike

给定这样的数据:

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的长度?

fiddle :http://jsfiddle.net/RBSC9/


以下不起作用:

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

http://jsfiddle.net/RBSC9/2/

关于javascript - json值的长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17487916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com