I am using fasterxml.jackson. I am confused about readValue()
. Here is my question.
I know jackson deserialize normal JavaBean and Collection in two different ways.
For JavaBean, we can pass MyBean.class
or new TypeReference<MyBean>
to readValue()
. For Collections, we must pass new TypeReference<List<MyBean>>
. That is because TypeReference
saves the type erased by Collection. Am I right? :)
Now I am confused. If MyBean
contains a list, then I can still pass MyBean.class
and it works. How does jackson do that?
public class MyBean {
String str;
List<String> strList;
}