ServletHelpers { public static JSONObject readObject(BufferedReader reader) throws IOException { String data = IOHelper.readFully(reader); return new JSONObject(data); }  static void doForbidden(HttpServletResponse response); static void doForbidden(HttpServletResponse response, ForbiddenReason reason); static void doAuthPrompt(String realm, HttpServletResponse response); static void sendJSONResponse(HttpServletResponse response, boolean value); static void sendJSONResponse(HttpServletResponse response, String json); static JSONObject readObject(BufferedReader reader); static void writeEmpty(PrintWriter out); static void writeObject(Converters converters, JsonConvertOptions options, PrintWriter out, Object data); static Map populateTableMapForXl(List listEntry); static Map populateErrorTableMapForXl(List listEntry); static String generateCsvString(Map xlData); static List flatten(List list); static Set flatten(Set set); static String removeNoisyString(Object value); static InputStream loadFile(String path);  }
@Test public void readObject() throws Exception { String data = "{ string: 'text', number: 2, boolean: true }"; JSONObject json = ServletHelpers.readObject( new BufferedReader(new InputStreamReader(new ByteArrayInputStream(data.getBytes())))); assertThat(json.get("string"), equalTo("text")); assertThat(json.get("number"), equalTo(2)); assertThat(json.get("boolean"), equalTo(true)); }