cn.tenmg.flink.jobs.utils.JSONUtils Maven / Gradle / Ivy
package cn.tenmg.flink.jobs.utils;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
/**
* JSON工具类
*
* @author June [email protected]
*
* @since 1.1.2
*/
public abstract class JSONUtils {
/**
* 将参数集转化为JSON字符串
*
* @param params
* 参数集
* @return 返回参数集的JSON字符串
*/
public static final String toJSONString(Map params) {
if (params != null) {
StringBuilder sb = new StringBuilder("{");
boolean flag = false;
for (Iterator> it = params.entrySet().iterator(); it.hasNext();) {
Entry entry = it.next();
Object value = entry.getValue();
if (flag) {
sb.append(", ");
} else {
flag = true;
}
appendKey(sb, entry.getKey());
append(sb, value);
}
sb.append("}");
return sb.toString();
}
return null;
}
/**
* 将参数集转化为JSON字符串
*
* @param params
* 参数集
* @return 返回参数集的JSON字符串
*/
public static final String toJSONString(Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy