官方维基:新手指南;
示例数据1:
String jsonString =
{
"edges": {
"oim-6i8-1lp1-6h4": {
"id": "oim-6i8-1lp1-6h4",
"label": "link.legalperson",
"linkName": "法人关系",
"source": "8432",
"target": "8392",
"propertyList": [
{
"propertyName": "数据来源ID",
"propertyKey": "dataSourcesId",
"propertyValue": "630cfb50b0c74ba6bb37038a2da545d6",
"statistics": true,
"timeline": false
},
{
"propertyName": "数据来源类型",
"propertyKey": "dataSourcesType",
"propertyValue": "MA",
"statistics": true,
"timeline": false
}
]
}
},
"edgesMeta": {
"link.legalperson": {
"color": "050ff6",
"labelName": "法人关系"
}
},
"nodes": {
"8392": {
"id": "8392",
"label": "object.enterprise",
"objectName": "振德医疗用品股份有限公司",
"extObjectProMap": {},
"propertyList": []
},
"8432": {
"id": "8432",
"label": "object.person",
"objectName": "张某",
"extObjectProMap": {},
"propertyList": []
}
},
"nodesMeta": {
"object.enterprise": {
"iconColor": "ebf1fc",
"icon": "F0F7",
"backgroundColor": "7076ed",
"labelName": "单位",
"category": "entity"
},
"object.person": {
"iconColor": "ebf1fc",
"icon": "F183",
"backgroundColor": "7076ed",
"labelName": "人员",
"category": "entity"
}
},
"paths": [
{
"edgeIds": [
"oim-6i8-1lp1-6h4"
],
"nodeIds": [
"8392",
"8432"
]
}
],
"sourceNode": "8432",
"targetNode": "8392"
}
处理代码1:
// 1.json字符串转换为JSONObject
JSONObject jsonObject = (JSONObject) JSON.parse(jsonString);
// 2.获取某一元素对应值(比如edges)
JSONObject edges = (JSONObject) jsonObject.get("edges");
// 3.JSONObject转换为Map
Map<String, Object> edgesMap = JSONObject.toJavaObject(edges, Map.class);
// 4.遍历map
Iterator<Map.Entry<String, Object>> edgesIterator = edgesMap.entrySet().iterator();
while (edgesIterator.hasNext()) {
Map.Entry<String, Object> entry = edgesIterator.next();
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
示例数据2:
{
"edgesMeta": {
"link.legalperson": {
"color": "050ff6",
"labelName": "法人关系"
}
},
"nodes": [
{
"id": "8392",
"label": "object.enterprise",
"objectName": "振德医疗用品股份有限公司",
"extObjectProMap": {},
"propertyList": []
}
],
"edges": [
{
"id": "oim-6i8-1lp1-6h4",
"label": "link.legalperson",
"linkName": "法人关系",
"source": "8432",
"target": "8392",
"propertyList": [
{
"propertyName": "数据来源ID",
"propertyKey": "dataSourcesId",
"propertyValue": "630cfb50b0c74ba6bb37038a2da545d6",
"statistics": true,
"timeline": false
},
{
"propertyName": "数据来源类型",
"propertyKey": "dataSourcesType",
"propertyValue": "MA",
"statistics": true,
"timeline": false
}
]
}
],
"nodesMeta": {
"object.enterprise": {
"iconColor": "ebf1fc",
"icon": "F0F7",
"backgroundColor": "7076ed",
"labelName": "单位",
"category": "entity"
}
}
}
处理代码2:
// 1.json字符串转换为JSONObject
JSONObject jsonObject = (JSONObject) JSON.parse(jsonString);
// 2.获取某一元素对应值(比如edges),并转换为JSONArray
JSONArray edges = (JSONArray) jsonObject.get("edges");
// 3.JSONArray转换为字符串
String edgesStr = JSONArray.toJSONString(edges);
// 4.json字符串转换为List
List<Map> edgesList = JSONArray.parseArray(edgesStr, Map.class);
最新评论
网飞没问题, 迪士尼+有解决方案么?
pp助手是安卓手机用的,根本下载用不来苹果
已解决
这样的话数据库里的结构为{"attachment":{"content":"xxx"}}, 要怎么才能变成{"content":"xxx"},从而使结构保持一致?
赞! make test不过的坑都写到的,谢谢楼主~
谢谢你
用了root用户还是一直502是怎么回事呢
student id 是空的