Skip to content

Instantly share code, notes, and snippets.

@fuxingloh
Last active July 11, 2017 18:03
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 fuxingloh/586305abad870ac19951 to your computer and use it in GitHub Desktop.
Save fuxingloh/586305abad870ac19951 to your computer and use it in GitHub Desktop.
Jackson
ObjectMapper mapper = new ObjectMapper()
// Via class
Hey hey = mapper.readValue("{name:\"hey\"}", Hey.class);
System.out.println(hey.name);
// Via dynamic
JsonNode node = mapper.readTree("{name:\"hey\"}");
// With null safety, allows chaining
String name = node.path("name").asText();
// With no null safety
name = node.get("name").asText();
// Json Express
name = node.at("/name").asText();
System.out.println(name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment