【发布时间】:2011-04-22 12:54:59
【问题描述】:
我想发送json,里面有另一个json对象,像这样
{
"key1": "value1",
"key2": "valu2",
"content": {
"nestedkey1": "nestedValue1",
"nestedkey2": "nestedValue2"
}
}
里面的对象没有任何java表示,只是json格式的字符串。如何正确转换?
我的方法不正确,我总是收到嵌套 json 的空字符串。我为这个嵌套对象使用了 Map,但又为空地图。
public class Instance {
private String key1;
private int key2;
private String content;
public String getKey1 {
return key1;
}
public void setKey1(String key1) {
this.key1 = key1;
}
public BigDecimal getKey2() {
return key2;
}
public void setKey2(BigDecimal key2) {
this.key2 = key2;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
【问题讨论】: