2016-08-29 6 views
1

SpringでこのJSONをサポートすることは可能ですか? Javaで新しいオブジェクトを作成せずに、おそらくマップ?Spring RESTリストとオブジェクトでJSONをサポートする方法

JSON:

{ 
    "object":"1", 
    "list":[ 
       { 
        "id":"1" 
       } 
      ] 
} 

のJava:

@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) 
    public ResponseEntity<Map<String, Object>> getRecipe(@RequestBody What should I write in this place?){ 

答えて

1

はい、あなたは以下のようにHashMap使用していますが、それをしたくない理由があることを行うことができますか? RESTサービスに必要なプロパティを持つrequest用のJavaBeanクラスを個別に作成する必要があります。

@RequestMapping(value = "/upload/one", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) 
    public ResponseEntity<Map<String, Object>> getRecipe(@RequestBody HashMap<String, Object> request){ 
     System.out.println(request); 
     return null; 
    } 
+0

私はそれを行う方法が不思議でした –

関連する問題