|
@@ -1,6 +1,7 @@
|
|
package org.jeecg.modules.bytedance.common.utils;
|
|
package org.jeecg.modules.bytedance.common.utils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
@@ -63,4 +64,33 @@ public class Check {
|
|
public static boolean isNullMap(Map<?, ?> map) {
|
|
public static boolean isNullMap(Map<?, ?> map) {
|
|
return map == null || map.isEmpty();
|
|
return map == null || map.isEmpty();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 移除 JSONObject 中 value 为空的 key
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static JSONObject jsonRemoveEmpty(JSONObject jsonObject){
|
|
|
|
+ JSONObject jsonResult = new JSONObject();
|
|
|
|
+ for (Object key :jsonObject.keySet() ) {
|
|
|
|
+ String value =(String) jsonObject.get(key);
|
|
|
|
+ if (!Check.isNull(value)){
|
|
|
|
+ jsonResult.put(key.toString(), value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return jsonResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("advertiser_id", "123");
|
|
|
|
+ params.put("campaign_id", "123");
|
|
|
|
+ params.put("modify_time", null);
|
|
|
|
+ System.out.println(jsonRemoveEmpty(params));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|