I have an ArrayList of a class that looks like this:
public class Person {
String name;
String age
List<String> education = new ArrayList<String> ();
List<String> family = new ArrayList<String> ();
List<String> previousjobs = new ArrayList<String>();
}
I want to write this list as Json and tried this code:
Writer out = new PrintWriter("./test.json");
mapper.writerWithDefaultPrettyPrinter().writeValueas(out, persons);
and got this error message:
No serializer found for class ~~~~~~ and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])`
I tried adding mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
but it made all the Person Objects empty for some unknown reasons.
What am I getting wrong?