Вы можете создавать классы, подобные этим:
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
}
После этого вы можете использовать Jackson
для десериализации строки json
в JavaObject
объект, например:
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);