コード例 #1
0
ファイル: NavController.java プロジェクト: treejames/createsh
 @RequestMapping(value = "/type_map", method = RequestMethod.GET)
 public @ResponseBody JSONArray getTypeMap() {
   JSONArray jsonArray = new JSONArray();
   Map<Type, List<Category>> typeMap = productService.getTypeMap();
   for (Type key : typeMap.keySet()) {
     List<Category> categoryList = typeMap.get(key);
     JSONArray categoryJsonArray = new JSONArray();
     for (Category category : categoryList) {
       JSONObject jsonObject = new JSONObject();
       jsonObject.put("key", category.getCategory());
       jsonObject.put("value", category.toString());
       categoryJsonArray.add(jsonObject);
     }
     JSONObject jsonObject = new JSONObject();
     jsonObject.put("name", key.getType());
     jsonObject.put("value", key.toString());
     jsonObject.put("list", categoryJsonArray);
     jsonArray.add(jsonObject);
   }
   return jsonArray;
 }