获取长度的杰森对象 [英] Get Length Of Json object
本文介绍了获取长度的杰森对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有从php文件返回的json对象,json值如下
I have json object which is returned from php file, the json values are as follows
{
"0": {
"id": "35",
"name": "first name",
"date": "2014-03-03",
"age": "25"
},
"1": {
"id": "36",
"name": "name",
"date": "0000-00-00",
"age": "25"
},
"2": {
"id": "37",
"name": "myname",
"date": "0000-00-00",
"age": "25"
},
"average_age": 25,
"count": 3
}
如何获取除average_age和count以外的其他值的计数 那是给定的json对象,我想在jQuery中获得3作为长度
How do I get the count of values other than average_age and count that is for the given json object i want to get 3 as length in jQuery
推荐答案
我已经找到答案
Object.keys(result).length // returns 5
更新
根据评论,这不适用于IE 7和8
From the comment this does not work on IE 7 and 8
这篇关于获取长度的杰森对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文