Is ObjectMapper supposed to work with a class which only has private members, no constructor and no getter/setters ?
I tried this, but it does not solve the problem.
mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
Is ObjectMapper supposed to work with a class which only has private members, no constructor and no getter/setters ?
I tried this, but it does not solve the problem.
mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
http://www.baeldung.com/jackson-field-serializable-deserializable-or-not
static class MyDtoAccessLevel {
private String stringValue = "hidden";
}
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
MyDtoAccessLevel dtoObject = new MyDtoAccessLevel();
System.out.println(mapper.writeValueAsString(dtoObject));
//prints {"stringValue":"hidden"}
}