+ /**
+ * @param input The Stream is closed after being read
+ */
+ public static <T> T readJson(InputStream input, Class<T> type) throws IOException
+ {
+ try (InputStreamReader reader = new InputStreamReader(input); BufferedReader bf = new BufferedReader(reader))
+ {
+ return fromJson(bf.lines().collect(Collectors.joining("\n")), type);
+ }
+ }
+
+ public static <T> T fromJson(String src, Class<T> type)
+ {
+ // TODO actually parse and compare version
+ String rawJson = src.lines().dropWhile(s -> s.length() == 0 || s.charAt(0) != '{').collect(Collectors.joining());
+ return parser.fromJson(rawJson, type);
+ }
+