将 JSON 列表转换为 POJO
Turning JSON list into POJO
这是JSON:
{
"Want":{
"ABCD-1234-ABCD-1234-ABCD-125A":3,
"ABCD-1234-ABCD-1234-ABCD-129B":5,
"ABCD-1234-ABCD-1234-ABCD-123C":10
},
"EndPoint":"https://example.com/gossip/asff3"
}
我现在的 POJO:
public class WantMessage {
@JsonProperty("Want")
Map<String, String> wantmap = new HashMap<String, String>();
@JsonProperty("EndPoint")
public String EndPoint;
}
我得到了 "Endpoint" 字符串,但缺少 "Want" 部分中的数据。你会如何拉入需求列表?
wantmap
具有 String
类型的键和值。 json 中的地图有 int
个值。尝试将数字放在双引号中,看看是否有效。
这是JSON:
{
"Want":{
"ABCD-1234-ABCD-1234-ABCD-125A":3,
"ABCD-1234-ABCD-1234-ABCD-129B":5,
"ABCD-1234-ABCD-1234-ABCD-123C":10
},
"EndPoint":"https://example.com/gossip/asff3"
}
我现在的 POJO:
public class WantMessage {
@JsonProperty("Want")
Map<String, String> wantmap = new HashMap<String, String>();
@JsonProperty("EndPoint")
public String EndPoint;
}
我得到了 "Endpoint" 字符串,但缺少 "Want" 部分中的数据。你会如何拉入需求列表?
wantmap
具有 String
类型的键和值。 json 中的地图有 int
个值。尝试将数字放在双引号中,看看是否有效。