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
你能分享你的控制器嗎? –