JSON in Java

Jackson is the most common library for JSON in Java.

Key points

Jackson is the most common library for JSON in Java.

Parse JSON

ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(text, User.class);

Stringify JSON

String text = mapper.writeValueAsString(user);

Validate JSON

try {
  mapper.readTree(text);
} catch (JsonProcessingException e) {
  e.printStackTrace();
}