Created
February 8, 2022 14:53
-
-
Save jpukg/90f7200201812d1e4dd16bc46ad63e89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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