我正在从服务器向Android发送/接收自定义类,该类为;
import org.msgpack.value.Value; public class myClass { public String status; public Value data; }
问题是我总是得到错误;
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.msgpack.value.Value, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information at [Source: java.io.BufferedInputStream@f478759; line: -1, column: 100] (through reference chain:xxx.xxxxxxxxxx.xxx.xxxxxx.myClass["data"]
如果我改变变量"data" MAP
然后它工作正常,但数据是未知类型!(通常HashMap或数组可能是String,而不是其他类).
MessagePackFactory factory = new MessagePackFactory(); ObjectMapper mapper = new ObjectMapper(factory); myClass response = mapper.readValue(inputStream, myClass.class);
如何指定未知类型?