如何在angularjs中查找根节点json数据的子节点数

时间:2015-08-05 10:08:30

标签: json angularjs

我有以下JSON数据数组。有两个根节点,然后有根节点的子节点和子节点的子节点。我需要找到根节点有多少个子节点。我不知道该怎么做。

[
{
    "Id": "0",
    "Name": "Subscriber"
    "Suscribers": [
        {
            "Id": "0",
            "Name": "Suscriber 1"
            "Events": [
                {
                    "Id": "0",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"

                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"

                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                },
                {
                    "Id": "1",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"
                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                }
            ],
            "Actions": null
        },
        {
            "Id": "1",
            "Name": "Suscriber 1"
            "Events": [
                {
                    "Id": "0",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"


                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                },
                {
                    "Id": "1",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"
                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                }
            ],
            "Actions": null
        }
    ],
    "Actions": [
        {
            "Name": "Start",
            "Text": "Abc"
        },
        {
            "Name": "Start",
            "Text": "Abc"
        }
    ]
},
{
    "Id": "1",
    "Name": "Subscriber"
    "Suscribers": [
        {
            "Id": "0",
            "Name": "Suscriber 1"
            "Events": [
                {
                    "Id": "0",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"
                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                },
                {
                    "Id": "1",
                    "Name": "Subscriber"
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"
                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                }
            ],
            "Actions": null
        },
        {
            "Id": "1",
            "Name": "Suscriber 1"

            ,


            "Events": [
                {
                    "Id": "0",
                    "Name": "Subscriber"




                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"


                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"


                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                },
                {
                    "Id": "1",
                    "Name": "Subscriber
                    "Suscribers": [
                        {
                            "Id": "0",
                            "Name": "Suscriber 1"
                        },
                        {
                            "Id": "1",
                            "Name": "Suscriber 1"


                        }
                    ],
                    "Actions": [
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        },
                        {
                            "Name": "Start",
                            "Text": "Abc"
                        }
                    ]
                }
            ],
            "Actions": null
        }
    ],
    "Actions": [
        {
            "Name": "Start",
            "Text": "Abc"
        },
        {
            "Name": "Start",
            "Text": "Abc"
        }
    ]
}
]

0 个答案:

没有答案