映射到带有“孩子”下的孩子的JSON:[..] JAVA

时间:2012-06-07 05:41:45

标签: java 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,并将子项设置为“子项”:[..]标记:

[
{"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

0 个答案:

没有答案