标签:i++ event 解析json数据 color class TE string pre void
JSON数据格式:
{"EventType": "event_user_create","UserId": ["123", "124", "125"],"DepId":["depId"],"CorpId": "corpid"}
JAVA解析:
public static void main(String[] args) { String aaa="{\"EventType\": \"event_user_create\",\"UserId\": [\"123\", \"124\", \"125\"],\"DepId\":[\"depId\"],\"CorpId\": \"corpid\"}"; JSONObject object=JSONObject.fromObject(aaa); System.out.println(object); if(object.size()>0){ Object EventType = object.get("EventType"); System.out.println("EventType:"+EventType); JSONArray UserId = object.getJSONArray("UserId"); for(int i=0;i<UserId.size();i++){ Object object2 = UserId.get(i); System.out.println("UserId:"+object2); } System.out.println("UserId:"+UserId); JSONArray DepId = object.getJSONArray("DepId"); System.out.println("DepId:"+DepId); Object CorpId = object.get("CorpId"); System.out.println("CorpId:"+CorpId); } }
结果:
{"EventType":"event_user_create","UserId":["123","124","125"],"DepId":["depId"],"CorpId":"corpid"} EventType:event_user_create UserId:123 UserId:124 UserId:125 UserId:["123","124","125"] DepId:["depId"] CorpId:corpid
标签:i++ event 解析json数据 color class TE string pre void
原文地址:https://www.cnblogs.com/zhuziyu/p/9176795.html