Jackson Deserialize Key/Value List into List<Class>

361 views Asked by At

I have a response from web service call like this

// other key/values
properties: {
   1000:true
   2000:false
   2939:true
   ...
}
// other key/values

I want to deserialize it to a POJO List which is

public class Service implements Serializable {
   private Integer id;
   private Boolean readOnly;
   ...
}

So far i have tried

ObjectMapper mapper = new ObjectMapper();
user.setServices(mapper.convertValue(response.getProperties(), Service.class));

But it doesn't convert map directly to the List. How do i achieve this? Here are the details:

Where response.getProperties() returns

@JsonAnyGetter
public Map<Integer, Boolean> getProperties() {
    return properties;
}

And user.setServices

public void setServices(List<Service> services) {
        this.services = services;
    }
0

There are 0 answers