源数据格式(list)
{
"dataPoint": {
"value": 1.0,
"timestamp": 1508208780000
},
"resourceId": 11150,
"resourceName": "duanzhenshuai.sunyainfo.com",
"metricId": 10720,
"metricName": "Availability"
},
{
"dataPoint": {
"value": 0.00530464217547344,
"timestamp": 1508208600000
},
"resourceId": 11150,
"resourceName": "duanzhenshuai.sunyainfo.com",
"metricId": 10722,
"metricName": "Transfer"
},
{
"dataPoint": {
"value": 0.3743428756508957,
"timestamp": 1508208600000
},
"resourceId": 11150,
"resourceName": "duanzhenshuai.sunyainfo.com",
"metricId": 10725,
"metricName": "CpuUsage"
}
目的数据格式
"data": {
"Availability": "1.0",
"Transfer": "0.00530464217547344",
"CpuUsage": "0.3743428756508957"
}
给出java或json的解决方案都可以,目前只能想到if-else或switch-case判断,但这样如果增添字段会非常麻烦?求指点