2
努力使用Spring Controller以下面的格式显示JSON数组。在Spring中显示JSON多维数组
[
["Apple","Red",[100,10]],
["Orange","Orange",[150,8]]
]
我正在使用杰克逊库。
我的控制器:
@Controller
@RequestMapping("/fruits")
public class FruitController {
@RequestMapping(value="{id}", method = RequestMethod.GET)
public @ResponseBody Fruit getLocationInJSON(@PathVariable String id) {
Fruit fruit = new Fruit();
fruit.setName("Apple");
fruit.setColor("Huningue");
fruit.setNumbers(new String[]{"100", "10"});
return fruit;
}
}
谢谢你在前进,
Selvaraj
你到目前为止尝试 –
{“name”:“Apple “,”颜色“:”红色“,”数字“:[”100“,”10“]} – Selvaraj
你能分享你的控制器吗? –