Question

I have same problem with this one and it's great to see this with a solution already. but I cant implement it on my code.

(Cannot deserialize instance of object out of START_ARRAY token in Spring 3 REST Webservice)

here's mine

MyModelClass modelClass=restTemplate.postForObject(url,mvm,MyModelClass.class);

based on the answer on the link a gave, I should replace MyModelClass.class by a List containing MyModelClass but I'm getting a syntax error.like this one

MyModelClass modelClass=restTemplate.postForObject(url,mvm,List<MymodelClass>);

Am I doing it wrong? Thanks in advance.

Was it helpful?

Solution

I got it weeks ago, and I feel that I should post my solution here for future use.

My JSON Response structure is a list of key value pairs, so what I did is

List<HashMap<String,String>> map=restTemplate.porsForObject(url,mvm,List.class);

The JSON response was converted into a map. So it is easy now to access the data by doing this.

String data= (Hashmap) map.get(position).get(key);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top