Package org.ghotibeaun.json.parser
Interface JSONParser
- All Known Subinterfaces:
JSONCSVParser
public interface JSONParser
JSON Parser interface.
- Author:
- Jim Earley (xml.jim@gmail.com)
-
Method Summary
Modifier and Type Method Description JSONArraynewJSONArray()Create an empty JSONArrayJSONObjectnewJSONObject()Create an empty JSONObjectJSONNodeparse(File file)Parse from a File<T> Tparse(File file, Class<T> targetClass)Parse and marshal JSON data to Class instanceJSONNodeparse(InputStream inputStream)Parse from an InputStream.<T> Tparse(InputStream inputStream, Class<T> targetClass)Parse and marshal JSON data to a Class instanceJSONNodeparse(InputStream inputStream, String charSet)Parse from an InputStream using a defined character<T> Tparse(InputStream inputStream, String charSet, Class<T> targetClass)Parse and marshal JSON data to a Class instanceJSONNodeparse(Reader reader)Parse from a Reader<T> Tparse(Reader reader, Class<T> targetClass)Parse and marshal JSON data to Class instanceJSONNodeparse(String data)Parse from a String<T> Tparse(String data, Class<T> targetClass)Parse and marshal JSON data to Class instanceJSONNodeparse(URL url)Parse from a URL.<T> Tparse(URL url, Class<T> targetClass)Parse and marshal JSON data to Class instanceJSONNodeparse(Path filePath)Parse from a Path reference<T> Tparse(Path filePath, Class<T> targetClass)Parse and marshal JSON data to Class instance
-
Method Details
-
parse
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
Parse from an InputStream using a defined character- Parameters:
inputStream- the InputStreamcharSet- The Character Set- Returns:
- A JSONNode instance
- Throws:
JSONParserException- thrown if parsing error occurs
-
parse
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
Parse from a String- Parameters:
data- the String data- Returns:
- a JSONNode instance
- Throws:
JSONParserException- thrown if parsing error occurs
-
parse
Parse from a Reader- Parameters:
url- the Reader implementation- Returns:
- a JSONNode instance
- Throws:
JSONParserException- thrown if parsing error occurs
-
parse
Parse from a File- Parameters:
file- the File- Returns:
- a JSONNode instance
- Throws:
JSONParserException- thrown if parsing error occurs
-
parse
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
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-8targetClass- 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 JSONParserExceptionParse 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 InputStreamcharSet- The Character SettargetClass- the target class- Returns:
- an instance of the specified class
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-
parse
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 URLtargetClass- the target class- Returns:
- an instance of the specified class
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-
parse
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 datatargetClass- the target concrete class to instantiate- Returns:
- an instance of the targetClass
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-
parse
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 implementationtargetClass- the target concrete class to instantiate- Returns:
- an instance of the targetClass
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-
parse
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 referencetargetClass- the target concrete class to instantiate- Returns:
- an instance of the targetClass
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-
parse
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 referencetargetClass- the target concrete class to instantiate- Returns:
- an instance of the targetClass
- Throws:
JSONParserException- thrown if parsing or marshalling error occcurs
-