Last active
November 19, 2018 09:49
-
-
Save gtudan/77a942873260756c912aad9c2fb947fa to your computer and use it in GitHub Desktop.
Customizing JSON-B output using Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = new JsonbConfig() | |
.withFormatting(true) // indents the output - default is false | |
.withNullValues(true); // show null fields - default is false | |
var jsonb = JsonbBuilder.create(config); | |
var json = jsonb.toJson(new Greeting("Hello World!")); | |
System.out.println(json); | |
/* | |
{ | |
"created": "2018-11-18", | |
"greeting": "Hello World!" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment