commit code
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.ydw.bat.wkflow.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年03月04日 17:13
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static Map<String, JSONArray> jsonArrGroup(JSONArray arr, String groupName, String sGroupName) {
|
||||
Map<String, JSONArray> map = new HashMap<>();
|
||||
String tempIdStr = "";
|
||||
JSONArray list;
|
||||
for(Object obj : arr){
|
||||
JSONObject jsonObject = (JSONObject) obj;
|
||||
tempIdStr = jsonObject.getString(groupName);
|
||||
if(tempIdStr.equals("")){
|
||||
continue;
|
||||
}
|
||||
if(map.containsKey(tempIdStr)){
|
||||
list = map.get(tempIdStr);
|
||||
list.add(obj);
|
||||
}else{
|
||||
list = new JSONArray();
|
||||
list.add(obj);
|
||||
map.put(tempIdStr, list);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user