Deserialize json with Java parameterized constructor
12 Sep 2016 3 mins read jackson java jsonIn my previous blog JSON deserialize generic types using Gson and Jackson I talked about how you can deserialize JSON using Java Generics. Now in this blog post, we are going to learn how to deserialize JSON into a Java class that doesn’t have a default constructor. For this blog, I am using the Jackson library.
Almost all frameworks require a default(no-argument) constructor in your class because these frameworks use reflection to create objects by invoking the default constructor but if there is no default constructor present in class then its hard to instantiate it using reflection. Let’s assume we have a class with a no-args constructor (only a parameterized constructor present) and we want to deserialize it.