Object对象:
public class ListJson {
private String first;
private String second;
}
public class JsonListMap {
private String userName ;
private List<ListJson> testList;
private Map<String, List<ListJson>> testMap;
}
传参接口:
@RequestMapping("test")
public class JsonListMapController {
@PostMapping("json")
public void jsonRec(@RequestBody JsonListMap j) {
System.out.println("接收成功");
}
}
Json传参:
{}:对象 []:数组和集合 :属性和值
{
//userName 对应 JsonListMap的属性userName
"userName":"haha",
//testList 和 JsonListMap的属性名对应
"testList":[
{
//前面的first、second 对应JsonList 的属性名
"first":"first",
"second":"second"
},
{
"first":"ff",
"second":"ss"
}
],
// testMap 对应 JsonListMap的属性testMap
"testMap":{
// testKey 为testMap的键String 的值
"testKey":[
{
"first":"first",
"second":"second"
},
{
"first":"ff",
"second":"ss"
}
]
}
}
传数组:“byteArray”:[ “1”,“2”]