Skip to content

Instantly share code, notes, and snippets.

@jpukg
Created February 8, 2022 14:53
Show Gist options
  • Save jpukg/90f7200201812d1e4dd16bc46ad63e89 to your computer and use it in GitHub Desktop.
Save jpukg/90f7200201812d1e4dd16bc46ad63e89 to your computer and use it in GitHub Desktop.
public static ObjectMapper configureMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return mapper;
}
public static void main(String[] args) throws JsonProcessingException {
String jsonData = "{\"success\":\"true\",\"message\":\"\",\"data\":[{\"employeId\":\"jp\"}]}";
Root root = configureMapper().readValue(jsonData, Root.class);
System.out.println(root);
}
}
class Employee {
public String employeeId;
public String employeId;
}
class Root {
public boolean success;
public String message;
@JsonProperty("data")
public List<Employee> data1 = new ArrayList<>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment