public static void main(String[] args) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
public static void main(String[] args) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
- mapper.writeValue(System.out, new Bar());
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ String str = mapper.writeValueAsString(new Bar());
+ System.out.println(str);