Interface JSONParser

All Known Subinterfaces:
JSONCSVParser

public interface JSONParser
JSON Parser interface.
Author:
Jim Earley (xml.jim@gmail.com)
  • Method Details

    • parse

      JSONNode parse​(InputStream inputStream) throws JSONParserException
      Parse from an InputStream. Character Set defaults to UTF-8
      Parameters:
      inputStream - the InputStream
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(InputStream inputStream, String charSet) throws JSONParserException
      Parse from an InputStream using a defined character
      Parameters:
      inputStream - the InputStream
      charSet - The Character Set
      Returns:
      A JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(URL url) throws JSONParserException
      Parse from a URL. Converts it to an InputStream
      Parameters:
      url - the fully qualified URL
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(String data) throws JSONParserException
      Parse from a String
      Parameters:
      data - the String data
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(Reader reader) throws JSONParserException
      Parse from a Reader
      Parameters:
      url - the Reader implementation
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(File file) throws JSONParserException
      Parse from a File
      Parameters:
      file - the File
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • parse

      JSONNode parse​(Path filePath) throws JSONParserException
      Parse from a Path reference
      Parameters:
      filePath - the Path reference
      Returns:
      a JSONNode instance
      Throws:
      JSONParserException - thrown if parsing error occurs
    • newJSONObject

      JSONObject newJSONObject()
      Create an empty JSONObject
      Returns:
      the JSONObject
    • newJSONArray

      JSONArray newJSONArray()
      Create an empty JSONArray
      Returns:
      the JSONArray
    • parse

      <T> T parse​(InputStream inputStream, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to a Class instance
      Type Parameters:
      T - the Class type. Could be the target class type, a superclass or interface
      Parameters:
      inputStream - The InputStream. Character Set defaults to UTF-8
      targetClass - the target class reference
      Returns:
      an instance of the specified class
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(InputStream inputStream, String charSet, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to a Class instance
      Type Parameters:
      T - the Class type. Could be the target class type, a superclass or interface
      Parameters:
      inputStream - The InputStream
      charSet - The Character Set
      targetClass - the target class
      Returns:
      an instance of the specified class
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(URL url, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to Class instance
      Type Parameters:
      T - The Class type. Could be the target class type, a superclass or interface
      Parameters:
      url - the fully qualified URL
      targetClass - the target class
      Returns:
      an instance of the specified class
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(String data, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to Class instance
      Type Parameters:
      T - The Class type. Could be the target class type, a superclass or interface
      Parameters:
      data - the String data
      targetClass - the target concrete class to instantiate
      Returns:
      an instance of the targetClass
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(Reader reader, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to Class instance
      Type Parameters:
      T - The Class type. Could be the target class type, a superclass or interface
      Parameters:
      reader - The Reader implementation
      targetClass - the target concrete class to instantiate
      Returns:
      an instance of the targetClass
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(File file, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to Class instance
      Type Parameters:
      T - The Class type. Could be the target class type, a superclass or interface
      Parameters:
      file - The File reference
      targetClass - the target concrete class to instantiate
      Returns:
      an instance of the targetClass
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs
    • parse

      <T> T parse​(Path filePath, Class<T> targetClass) throws JSONParserException
      Parse and marshal JSON data to Class instance
      Type Parameters:
      T - The Class type. Could be the target class type, a superclass or interface
      Parameters:
      filePath - the Path reference
      targetClass - the target concrete class to instantiate
      Returns:
      an instance of the targetClass
      Throws:
      JSONParserException - thrown if parsing or marshalling error occcurs