估计你是用了 fastjson 转换,fastjson 只认 getter 方法,所以会调用 record 里头的 getColumns() 方法来转换
解决办法是加配置: SerializeConfig.getGlobalInstance().put(Record.class, new FastJsonRecordSerializer());
此外,还要创建一个类来支持:
/** * FastJsonRecordSerializer 支持序列化 activerecord 的 Record 类型 */ public class FastJsonRecordSerializer implements ObjectSerializer {
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { if (object != null) { Record record = (Record)object; serializer.write(record.getColumns()); } } }
解决办法是加配置:
SerializeConfig.getGlobalInstance().put(Record.class, new FastJsonRecordSerializer());
此外,还要创建一个类来支持:
/**
* FastJsonRecordSerializer 支持序列化 activerecord 的 Record 类型
*/
public class FastJsonRecordSerializer implements ObjectSerializer {
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
if (object != null) {
Record record = (Record)object;
serializer.write(record.getColumns());
}
}
}