我现在的代码:
@GetMapping("floordata")
public Map<String,Object> floordata() {
Map<String,Object> map = new HashMap<>();
Object floor_title = floorDataService.floortitle();
List<FloorData> product_list = floorDataService.floorproduct();
map.put("floor_title",floor_title);
map.put("product_list",product_list);
return map;
}
返回的json
{
floor_title: [
{
name: "时尚女装",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_title.png",
image_width: null,
open_type: null,
navigator_url: null
}
],
product_list: [
{
name: "优质服饰",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_1@2x.png",
image_width: "232",
open_type: "navigate",
navigator_url: "/pages/goods_list/goods_list?query=服饰"
},
{
name: "春季热门",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_2@2x.png",
image_width: "233",
open_type: "navigate",
navigator_url: "/pages/goods_list/index?query=热"
},
]
}
我希望返回的json形式(主要是floor_title里我想要返回的形式是name和image_src在集合里,而不是在数组里,该如何修改?)
{
floor_title: {
name: "时尚女装",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_title.png"
},
product_list: [
{
name: "优质服饰",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_1@2x.png",
image_width: "232",
open_type: "navigate",
navigator_url: "/pages/goods_list?query=服饰"
},
{
name: "春季热门",
image_src: "https://api-hmugo-web.itheima.net/pyg/pic_floor01_2@2x.png",
image_width: "233",
open_type: "navigate",
navigator_url: "/pages/goods_list?query=热"
}
]
},