java对象转成json成立的基本条件只需要有get方法
public class ResultView<DATA> {
public long getTimestamp() {
return System.currentTimeMillis();
}
public String getHostname() {
return HostInfo.getHostName();
}
}
则ObjectMapperUtils.toJSON(resultView)的结果是{hostname":"MacBook-Pro.local","timestamp":1650543262512},所以get方法可以把java对象可自动转为json
标签:return,java,get,json,相关,getHostname,public From: https://www.cnblogs.com/MarkLeeBYR/p/17502282.html