5
MsgAttachment 是 interface
CustomAttachment implements MsgAttachment
直接进行JSON.parser( json, MsgAttachment.class) 会丢失 CustomAttachment 的属性。
请问如何进行ParserConfig设置,能够正确反序列化出 CustomAttachment ?
ParserConfig.getGlobalInstance().putDeserializer(MsgAttachment.class, new ObjectDeserializer() {
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
//此处已经能正确获得 CustomAttachment 在序列化之后的 字符串了
//这里应该如何创建一个对象?
return null;
}
});