Skip to content

Instantly share code, notes, and snippets.

@biniama
Created November 2, 2018 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biniama/7d9c7611061c7c85588f1314c4e8e398 to your computer and use it in GitHub Desktop.
Save biniama/7d9c7611061c7c85588f1314c4e8e398 to your computer and use it in GitHub Desktop.
Convert POJO to JSON
import com.fasterxml.jackson.databind.ObjectMapper;
private static void pojoToJson(Object object) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
log.info(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment