mirror of https://gitee.com/stylefeng/roses
【7.2.5】【wrapper】更新序列化策略
parent
902ae21c22
commit
ffd149e4dc
|
@ -56,9 +56,7 @@ public class EnumFieldFormatSerializer extends JsonSerializer<Object> {
|
|||
}
|
||||
|
||||
// 进行数据转化写入到渲染的JSON中
|
||||
if (!originValue.equals(formattedValue)) {
|
||||
CommonFormatUtil.writeField(formatTypeEnum, originValue, formattedValue, jsonGenerator);
|
||||
}
|
||||
CommonFormatUtil.writeField(formatTypeEnum, originValue, formattedValue, jsonGenerator);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,7 @@ public class SimpleFieldFormatSerializer extends JsonSerializer<Object> {
|
|||
Object formattedValue = simpleFieldFormatProcess.formatProcess(originValue);
|
||||
|
||||
// 将转化的值,根据策略,进行写入到渲染的json中
|
||||
if (!originValue.equals(formattedValue)) {
|
||||
CommonFormatUtil.writeField(formatTypeEnum, originValue, formattedValue, jsonGenerator);
|
||||
}
|
||||
CommonFormatUtil.writeField(formatTypeEnum, originValue, formattedValue, jsonGenerator);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,12 @@ public class CommonFormatUtil {
|
|||
*/
|
||||
public static void writeField(FormatTypeEnum formatTypeEnum, Object originValue, Object formattedValue, JsonGenerator jsonGenerator) {
|
||||
try {
|
||||
// 如果原始值和转化值一样,则直接返回
|
||||
if (originValue.equals(formattedValue)) {
|
||||
jsonGenerator.writeObject(originValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果转化模式是替换类型
|
||||
if (formatTypeEnum.equals(FormatTypeEnum.REPLACE)) {
|
||||
jsonGenerator.writeObject(formattedValue);
|
||||
|
|
Loading…
Reference in New Issue