我與一些Json的工作類似於:JSON對象數組的長度
{
"Apps" : [
{
"Name" : "app1",
"id" : "1",
"groups" : [
{ "id" : "1", "name" : "test group 1", "desc" : "this is a test group" },
{ "id" : "2", "name" : "test group 2", "desc" : "this is another test group" }
]
}
]
}
如果我解析它在jQuery中返回一個對象,我通過應用程序,像這樣的迭代:
$.each(myJsonObject.Apps, function() { ... };
我怎樣才能得到this.groups
的長度?
我已經試過
- this.groups.length
- this.groups.length()
- $(本).groups.length()
和我在多層JSON對象中找不到任何有好信息的文檔。
任何鏈接或示例或建議,將不勝感激。
是不是隻是一個錯字? JSON中的'groups'全部爲小寫,但代碼示例具有'Groups'。 – 2011-04-07 19:56:45
即使在正確的情況下它也不起作用。生病更新我的例子 – Patrick 2011-04-07 19:58:39
你確定嗎?當我在控制檯中試用它時,它工作正常。 – 2011-04-07 20:01:47