【发布时间】:2019-02-21 00:05:36
【问题描述】:
json结构如下:
{
"key":"Key",
"value":{
"first": "first",
"second": "second"
}
}
我想使用 Spring Boot 将此 json 作为 Plain Old Java Object。
public class File {
private String key;
private JsonObject value;
public File(String key, JsonObject value) {
this.key = key;
this.value = value;
}
public File() {
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public JsonObject getValue() {
return value;
}
public void setValue(JsonObject value) {
this.value = value;
}
}
JsonObject - lib com.google.gson中的类
我得到{}
将字段“值”作为 String 是完美的,但 JsonObject 也可以。
【问题讨论】: