计算嵌套JSON中的所有子级

时间:2018-12-13 06:40:42

标签: json count tree

我有一个嵌套树JSON。我要计算所有“儿童”项目。我怎样才能做到这一点。

示例JSON

{
  "id": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44",
  "name": "htmd",
  "domain": "1f839aafbf7a41a1a0c88d40fd6cfe44.com",
  "phoneNumber": "",
  "address": "zxcads asd asd asd asd",
  "corporateIdentity": {
    "taxId": "123123",
    "taxOffice": "12312",
    "crsNo": "123123",
    "trsNo": null
  },
  "path": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44",
  "children": [
    {
      "id": "cbed3322-9b1e-4fd5-b90e-b2d0ed86337c",
      "name": "wqeqwe",
      "domain": "sd asd ad ads",
      "phoneNumber": "",
      "address": "123123",
      "corporateIdentity": {
        "taxId": "1231",
        "taxOffice": "12313",
        "crsNo": "231",
        "trsNo": ""
      },
      "path": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44,cbed3322-9b1e-4fd5-b90e-b2d0ed86337c",
      "children": [
        {
          "id": "de5ad96f-33ea-4d64-9b8f-1a6044e14091",
          "name": "sddddddd",
          "domain": "123123",
          "phoneNumber": "12312312312",
          "address": "3123123123123",
          "corporateIdentity": {
            "taxId": "1231",
            "taxOffice": "12313",
            "crsNo": "231",
            "trsNo": ""
          },
          "path": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44,cbed3322-9b1e-4fd5-b90e-b2d0ed86337c,de5ad96f-33ea-4d64-9b8f-1a6044e14091",
          "children": []
        },
        {
          "id": "cad667c7-2517-4452-ad76-12735cba5897",
          "name": "123123",
          "domain": "12312",
          "phoneNumber": "123213",
          "address": "123213123",
          "corporateIdentity": {
            "taxId": "312",
            "taxOffice": "1231",
            "crsNo": "231231231",
            "trsNo": "123123"
          },
          "path": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44,cbed3322-9b1e-4fd5-b90e-b2d0ed86337c,cad667c7-2517-4452-ad76-12735cba5897",
          "children": []
        },
        {
          "id": "4de8744c-8335-4bfd-a2b3-4495b6e17e73",
          "name": "qweq",
          "domain": "eqwewqe",
          "phoneNumber": "qweqwqwe",
          "address": "123213123",
          "corporateIdentity": {
            "taxId": "1231",
            "taxOffice": "12313",
            "crsNo": "231",
            "trsNo": ""
          },
          "path": "1f839aaf-bf7a-41a1-a0c8-8d40fd6cfe44,cbed3322-9b1e-4fd5-b90e-b2d0ed86337c,4de8744c-8335-4bfd-a2b3-4495b6e17e73",
          "children": []
        }
      ]
    }
  ]
}

0 个答案:

没有答案