I'm working on a Spring MVC project using angularjs, I'm passing from the view the following JSON array {name:"theName", code:"theCode", comment:"theComment", listOfIds:["3", "4"]}
This is my controller that receives the JSON
@RequestMapping(value = "/createPerson/", method = RequestMethod.POST)
public ResponseEntity<Void> createSep(@RequestBody final String DTOJsonObject,
UriComponentsBuilder ucBuilder) {
ObjectMapper mapper = new ObjectMapper();
Map<String, String> dataDTOParsed ;
dataDTOParsed = mapper.readValue(DTOJsonObject, HashMap.class);
//I tried this but it says that a String can not be converted to ArrayList<String>
ArrayList<String> listIDS = new ArrayList<String>();
listIDS = (ArrayList<String>) dataDTOParsed .get("listOfIds");
}
I tried using the following cast but it says that String can not be converted to ArrayList<String>
ArrayList<String> listIDS = new ArrayList<String>();
listIDS = (ArrayList<String>) dataDTOParsed .get(this);
I know how to get the other values is this value listOfIds:["3", "4"] that is giving me problems
Aucun commentaire:
Enregistrer un commentaire