Back to project page BehatReporter.
The source code is released under:
Copyright (C) 2013 Fabian Kiss <headrevision@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...
If you think the Android project BehatReporter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package headrevision.BehatReporter.json; //from www. jav a 2s .c o m import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.Closeables; public class Reader { private InputStream jsonStream; public Reader(InputStream jsonStream) { this.jsonStream = jsonStream; } public Reader(String json) { jsonStream = new ByteArrayInputStream(json.getBytes()); } @SuppressWarnings("deprecation") public JsonNode read() throws ReaderException { JsonNode jsonNode = null; ObjectMapper objectMapper = new ObjectMapper(); try { jsonNode = objectMapper.readTree(jsonStream); } catch (JsonParseException e) { throw (new ReaderException(e)); } catch (JsonProcessingException e) { throw (new ReaderException(e)); } catch (IOException e) { throw (new ReaderException(e)); } finally { Closeables.closeQuietly(jsonStream); } return jsonNode; } }