You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
public class Main2 {
public static void main(String[] args) {
//ParserConfig.getGlobalInstance().putDeserializer(Model.class, new ModelValueDeserializer());
String json = "{\"value\":123}";
Model model = JSON.parseObject(json, Model.class);
System.out.println(JSON.toJSONString(model));
}
public static class Model {
@JSONField(serializeUsing = ModelValueSerializer.class, deserializeUsing = ModelValueDeserializer.class)
public int value;
}
public static class ModelValueSerializer implements ObjectSerializer {
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
int features) throws IOException {
Integer value = (Integer) object;
String text = value + "元";
serializer.write(text);
}
}
public static class ModelValueDeserializer implements ObjectDeserializer {
@Override
public Integer deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
return parser.getLexer().intValue() * 100;
}
@Override
public int getFastMatchToken() {
return 0;
}
}
}
用下面的代码测试,发现并没有调用 @JSONField 注解上 deserializeUsing 指定的 ModelValueDeserializer 类?
版本 1.2.25, 1.2.32 以及最新的 1.2.43 都有问题