我希望我的JSON看起来像这样:
{
"information": [{
"timestamp": "xxxx",
"feature": "xxxx",
"ean": 1234,
"data": "xxxx"
}, {
"timestamp": "yyy",
"feature": "yyy",
"ean": 12345,
"data": "yyy"
}]
}
Run Code Online (Sandbox Code Playgroud)
代码到目前为止:
import java.util.List;
public class ValueData {
private List<ValueItems> information;
public ValueData(){
}
public List<ValueItems> getInformation() {
return information;
}
public void setInformation(List<ValueItems> information) {
this.information = information;
}
@Override
public String toString() {
return String.format("{information:%s}", information);
}
}
Run Code Online (Sandbox Code Playgroud)
和
public class ValueItems {
private String timestamp;
private String feature;
private int ean;
private String data; …Run Code Online (Sandbox Code Playgroud) 我有一个新创建的JsonNode
JsonNode jNode = new ObjectCodec().createObjectNode();
Run Code Online (Sandbox Code Playgroud)
使用此节点,我如何在其中添加键值对,以便我可以使用新值构造此新节点?我在http://www.cowtowncoder.com/blog/archives/2011/08/entry_460.html中提到的有关使用的内容
jNode.with("newNode").put("key1","value1");
Run Code Online (Sandbox Code Playgroud)
但是看看Jackson的JsonNode(v1.8)的API并没有显示任何方法.