mercredi 23 septembre 2015

Jackson ReadValue doesn't convert to List<>

I have a problem. I work with custom annotation, which takes method params and converts them from json to pojo. Here is example:

...
MethodParameter param 
// here a parameter from methods, marked with custom annotation
...
JSON_MAPPER.readValue(node, param.getParameterType());

java.util.LinkedHashMap cannot be cast to com.liferay.portal.kernel.util.KeyValuePair

But when I try to convert List<> it doesn't work. But the code below works fine

JSON_MAPPER.readValue(node, new TypeReference<List<KeyValuePair>>(){});

how I can figure out the type of income data? What should I do?





Aucun commentaire:

Enregistrer un commentaire