
com.app.common.utils.JsonUtils Maven / Gradle / Ivy
package com.app.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.util.List;
/**
* TODO
*
* @author fangfang.zhang
* @date 2021/4/22
*/
public class JsonUtils {
static {
JSON.DEFAULT_PARSER_FEATURE = (((((((0x0 | Feature.AutoCloseSource.getMask())
| Feature.InternFieldNames.getMask()) | Feature.UseBigDecimal.getMask())
| Feature.AllowUnQuotedFieldNames.getMask()) | Feature.AllowSingleQuotes.getMask())
| Feature.AllowArbitraryCommas.getMask()) | Feature.SortFeidFastMatch.getMask())
| Feature.IgnoreNotMatch.getMask();
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
JSON.DEFAULT_GENERATE_FEATURE = (((((0x0 | SerializerFeature.QuoteFieldNames.getMask())
| SerializerFeature.SkipTransientField.getMask()) | SerializerFeature.WriteEnumUsingToString.getMask())
| SerializerFeature.SortField.getMask()) | SerializerFeature.WriteDateUseDateFormat.getMask())
| SerializerFeature.DisableCircularReferenceDetect.getMask();
}
public static String Serializer(T paramT) {
return JSON.toJSONString(paramT);
}
public static byte[] SerializerBytes(T paramT) {
return JSON.toJSONBytes(paramT);
}
public static T Deserialize(String paramString, Class paramClass) {
return JSON.parseObject(paramString, paramClass);
}
public static T Deserialize(byte[] paramString, Class paramClass) {
return JSON.parseObject(paramString, paramClass);
}
public static List Deserialize2(String paramString, Class paramClass) {
return JSON.parseArray(paramString, paramClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy