转换代码
public static void main(String[] args) {
Person person = new Person();
person.setNAME("John");
person.setAGE(30);
person.setADDRESS("New York");
Gson gson = new Gson();
//String json = gson.toJson(person);
String datas= JSON.toJSONString(person);
System.out.println(datas);
}
@Data
class Person {
private String NAME;
private int AGE;
private String ADDRESS;
// getters and setters
}
最开始 把实体类转2次。
大家还是放弃吧