If I pass a JSON like
is it compulsory that my POJO should have both "name" and "age" instance variables
If you mean "have" as in the same names exactly, then no. You can use annotations to rename the values.
If you instead mean the class definition "contains" those values, then also it shouldn't need them. That depends on how you configure
ObjectMapper, though. For example, there is an
AnyGetter annotation that will allow you to collect "extra" JSON values. Therefore, it makes sense that mandatory fields are not required.