我有以下JSON
"ID": "234AS",
"Name": "SynchronousMate",
"Type": "Node",
"SubType": "SubNode",
"Dynamic": "Yes",
"DisplayName": "Sync",
"Direct": "Yes",
"Category": "IT",
"Properties": {
"Property": [
{
"Name": "A",
"Value": "Anant"
},
{
"Name": "B",
"Value": "Bharat"
},
{
"Name": "C",
"Value": "Cynus"
},
{
"Name": "D",
"Value": "Dynana"
},
{
"Name": "E",
"Value": "Elegant"
},
{
"Name": "Bank",
"Value": "BOB"
},
{
"Name": "ipAddress",
"Value": "101.90.34.12"
},
{
"Name": "siteName",
"Value": "BRS-WDM-PSS-X7A6"
},
{
"Name": "Longitude",
"Value": 0
},
{
"Name": "FullName",
"Value": "network:10.254.0.46"
},
{
"Name": "NumberOfShelves",
"Value": 0
},
{
"Name": "GEOCODE.Latitude",
"Value": 0
}
]
},
"Properties": ""
}
..............................
..............................
如何将此JSON转换为此类
{
"ID": "234AS",
"Name": "SynchronousMate",
"Type": "Node",
"SubType": "SubNode",
"Dynamic": "Yes",
"DisplayName": "Sync",
"Direct": "Yes",
"Category": "IT",
"A" : "Anant",
"B" : "Bharat",
"C" : "Cynus",
"D" : "Dynana",
"E" : "Elegant",
"Bank" : "BOB",
"ipAddress" : "101.90.34.12",
"siteName" : "BRS-WDM-PSS-X7A6",
"Longitude" : ""0",
"FullName" : "network:10.254.0.46",
"NumberOfShelves" : 0,
"GEOCODE.Latitude" : 0
},
............................
............................
答案 0 :(得分:0)
您可以循环properties
并创建一个Map
,其键值为Name
,值为Value
的值。
答案 1 :(得分:-1)
简单来说,获取/存储属性JsonArray。然后迭代它放入 Map中的数组元素。然后将地图添加到JSON的另一半。