/** * Reads a JSON value from the given string. * * @param text the string that contains the JSON value * @return the JSON value that has been read * @throws ParseException if the input is not valid JSON */ public static JsonValue readJSON(String text) { try { return new JsonParser(text).parse(); } catch(IOException exception) { // JsonParser does not throw IOException for String throw new RuntimeException(exception); } }
/** * Reads a JSON value from the given reader. * <p> * Characters are read in chunks and buffered internally, therefore wrapping an existing reader in * an additional <code>BufferedReader</code> does <strong>not</strong> improve reading * performance. * </p> * * @param reader the reader to read the JSON value from * @return the JSON value that has been read * @throws IOException if an I/O error occurs in the reader * @throws ParseException if the input is not valid JSON */ public static JsonValue readJSON(Reader reader) throws IOException { return new JsonParser(reader).parse(); }
/** * Reads a JSON value from the given reader. * <p> * Characters are read in chunks and buffered internally, therefore wrapping an existing reader in * an additional <code>BufferedReader</code> does <strong>not</strong> improve reading * performance. * </p> * * @param reader the reader to read the JSON value from * @return the JSON value that has been read * @throws IOException if an I/O error occurs in the reader * @throws ParseException if the input is not valid JSON */ public static JsonValue readJSON(Reader reader) throws IOException { return new JsonParser(reader).parse(); }
/** * Reads a JSON value from the given string. * * @param text the string that contains the JSON value * @return the JSON value that has been read * @throws ParseException if the input is not valid JSON */ public static JsonValue readJSON(String text) { try { return new JsonParser(text).parse(); } catch(IOException exception) { // JsonParser does not throw IOException for String throw new RuntimeException(exception); } }