Skip to content

Instantly share code, notes, and snippets.

@markscottwright
Created December 8, 2022 23:45
Show Gist options
  • Save markscottwright/dc047a323ba7e48029d203206976c4be to your computer and use it in GitHub Desktop.
Save markscottwright/dc047a323ba7e48029d203206976c4be to your computer and use it in GitHub Desktop.
How to pretty print json using java and Jackson
HashMap<String, Object> map = new ObjectMapper().readValue(jsonString, new TypeReference<HashMap<String, Object>>() {});
String prettyJson = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment