You can create classes like these:
class JavaObject {
private TimeObject time;
private String name;
//other fields
//getters and setters
}
class TimeObject {
private Date date;
private Time time;
//getters and setters
}
class Date {
private int year;
private int month;
private int day;
//getters and setters
}
class Time {
private int hour;
private int minute;
private int second;
private long nano;
//getters and setters
}
Once done, you can use Jackson to deserialize the json String into JavaObject object, e.g.:
ObjectMapper objectMapper = new ObjectMapper();
JavaObject javaObject = objectMapper.readValue("{\n" +
" \"time\":{\n" +
" \"date\":{\n" +
" \"year\":2017,\n" +
" \"month\":3,\n" +
" \"day\":12\n" +
" },\n" +
" \"time\":{\n" +
" \"hour\":10,\n" +
" \"minute\":42,\n" +
" \"second\":42,\n" +
" \"nano\":810000000\n" +
" }\n" +
" },\n" +
"\"name\":\"Jon\"}", JavaObject.class);
System.out.println(javaObject);
timeproperty. You can just parse everything to a JsonNode, get the inner Property as JsonNode and parse that to your POJO (see my answer).JSONstructure you can always generatePOJOmodel using online tools like it is described in this question: Array of JSON Object to Java POJO