From: Kai Moritz Date: Tue, 11 Aug 2020 06:48:46 +0000 (+0200) Subject: Explicitly record the generated serialization in a string X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=HEAD;p=demos%2Fnoanno Explicitly record the generated serialization in a string --- diff --git a/src/main/java/de/juplo/examples/jackson/SerializationExample.java b/src/main/java/de/juplo/examples/jackson/SerializationExample.java index 3b2819c..1da1e7c 100644 --- a/src/main/java/de/juplo/examples/jackson/SerializationExample.java +++ b/src/main/java/de/juplo/examples/jackson/SerializationExample.java @@ -14,7 +14,9 @@ public class SerializationExample { 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); } static class Foo {