Created
October 21, 2017 11:51
-
-
Save anonymous/a65426e55a33f09ab30ab32ffa70e06a to your computer and use it in GitHub Desktop.
This file contains 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
package so46861795; | |
import com.google.common.base.Charsets; | |
import com.google.common.io.Resources; | |
import com.google.gson.Gson; | |
import com.google.gson.reflect.TypeToken; | |
import lombok.Data; | |
import java.lang.reflect.Type; | |
import java.util.List; | |
public class App { | |
public static void main(String[] args) throws Exception { | |
final Type type = new TypeToken<List<Pair<OuterData, List<InnerData>>>>() {}.getType(); | |
final List<Pair<OuterData, List<InnerData>>> o = new Gson().fromJson(Resources.toString(Resources.getResource("so46861795/foo.json"), Charsets.UTF_8), type); | |
System.out.println(o.get(0).getFirst().getColor()); | |
} | |
@Data | |
static class Pair<F, S> { | |
F first; | |
S second; | |
} | |
@Data | |
static class OuterData { | |
String heading; | |
Integer color; | |
} | |
@Data | |
static class InnerData { | |
String name; | |
String category; | |
Integer categoryIcon; | |
String description; | |
String rules; | |
String time; | |
String date; | |
String venue; | |
Boolean notifyState; | |
Integer notifyTime; | |
Boolean favouriteState; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment