Вот, с помощью
Gson все парсится хорошо.
PS. вместо lombook.Data просто создайте геттеры/сеттеры у внутреннего класса. Мне так удобнее.
package com.mycompany;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Map.Entry;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class ReTest {
@lombok.Data
public static class MyData {
private String name;
private String lastName;
}
public static void main(String[] args) {
String json = "{\n" +
" \"12:30\": [\n" +
" {\n" +
" name: \"someName\",\n" +
" lastName: \"someLastName\"\n" +
" },\n" +
" {\n" +
" name: \"someName2\",\n" +
" lastName: \"someLastName2\"\n" +
" }\n" +
" ],\n" +
" \"13:15\": [\n" +
" {\n" +
" name: \"someName3\",\n" +
" lastName: \"someLastName3\"\n" +
" },\n" +
" {\n" +
" name: \"someName4\",\n" +
" lastName: \"someLastName4\"\n" +
" }\n" +
" ]\n" +
"}";
Gson parser = new Gson(); // create json parser
Type type = new TypeToken<Map<String, MyData[]>>(){}.getType(); // create custom type
Map<String, MyData[]> data = parser.fromJson(json, type); // parse data to
for( Entry<String, MyData[]> d: data.entrySet()) {
System.out.printf("%s\n", d.getKey());
for(MyData e: d.getValue()) {
System.out.printf(" %s\n", e);
}
System.out.println();
}
}
}
И вывод.
12:30
ReTest.MyData(name=someName, lastName=someLastName)
ReTest.MyData(name=someName2, lastName=someLastName2)
13:15
ReTest.MyData(name=someName3, lastName=someLastName3)
ReTest.MyData(name=someName4, lastName=someLastName4)