try {
Reader reader = new InputStreamReader(stream, Charsets.UTF_8);
String jsonString = CharStreams.toString(reader);
stream.close();
Factory factory = AutoBeanFactorySource.create(Factory.class);
return AutoBeanCodex.decode(factory, ApiDirectory.class, jsonString).as();
} catch (IOException e) {
fail("IOException: " + e.getMessage());
}
return null;