如何将嵌套的JSON输入发送到Restful Web服务(使用Java)?
例如。 JSON输入
{
"item1": [
{
"name": "name1",
"value": "value1",
"subitems": [
{
"sname": "sname1",
"svalue": "svalue1"
},
{
"sname": "sname2",
"svalue": "svalue2"
}
],
"attributes": [
{
"length": 25,
"height": 25,
"width": 30
},
{
"length": 35,
"height": 35,
"width": 40
}
]
}
]
}
答案 0 :(得分:0)
您可以创建一个类来映射json,如下所示:
public class item {
private String name;
private String value;
private List<SubItem> subitems;
private List<Attribute> attributes;
// add here getters, setters and constructor
}
public class SubItem{
private String name;
private String svalue;
//add here getters, setters and constructor
}
public class Attribute{
private Integer length;
private Integer height;
private Integer width;
//add here getters, setters and constructor
}