com.gateway.connector.utils.JsonUtils Maven / Gradle / Ivy
package com.gateway.connector.utils;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
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);
}
}