1

我有一张这样的地图:

 { 
     facility-1={facility-kind1={param1=XPath-1, param2=XPath-2}, 
            facility-kind2={param1=XPath-1, param2=XPath-2}
           },
    facility-2={facility-kind1={param1=XPath-1, param2=XPath-2}, 
            facility-kind2={param1=XPath-1, param2=XPath-2}
         }
  }

我想将其格式化为JSON“孩子”下的孩子:[ .. ] 标签:

[
{"title": "Item 1"},

{"title": "Folder 2",
    "children": [
        {"title": "Sub-item 2.1"},
    {"title": "Sub-item 2.2"}
        ]
    },

{"title": "Folder 3",
    "children": [

        {"title": "Sub-item 3.1"},

        {"title": "Sub-item 3.2"}

        ]

    }
]

当我使用时,JSON我没有得到孩子标签:

{
    "facility-1": {
        "facility-kind1": {
            "param1": "XPath-1",
            "param2": "XPath-2"
        },
        "facility-kind2": {
            "param1": "XPath-1",
            "param2": "XPath-2"
        }
    },
    "facility-2": {
        "facility-kind1": {
            "param1": "XPath-1",
            "param2": "XPath-2"
        },
        "facility-kind2": {
            "param1": "XPath-1",
            "param2": "XPath-2"
        }
    }
}

这不是我想要的。

我怎样才能得到JSON我想要的格式?

4

0 回答 0