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 JSONArray
newJSONArray()
Create an empty JSONArrayJSONObject
newJSONObject()
Create an empty JSONObjectJSONNode
parse(File file)
Parse from a File<T> T
parse(File file, Class<T> targetClass)
Parse and marshal JSON data to Class instanceJSONNode
parse(InputStream inputStream)
Parse from an InputStream.<T> T
parse(InputStream inputStream, Class<T> targetClass)
Parse and marshal JSON data to a Class instanceJSONNode
parse(InputStream inputStream, String charSet)
Parse from an InputStream using a defined character<T> T
parse(InputStream inputStream, String charSet, Class<T> targetClass)
Parse and marshal JSON data to a Class instanceJSONNode
parse(Reader reader)
Parse from a Reader<T> T
parse(Reader reader, Class<T> targetClass)
Parse and marshal JSON data to Class instanceJSONNode
parse(String data)
Parse from a String<T> T
parse(String data, Class<T> targetClass)
Parse and marshal JSON data to Class instanceJSONNode
parse(URL url)
Parse from a URL.<T> T
parse(URL url, Class<T> targetClass)
Parse and marshal JSON data to Class instanceJSONNode
parse(Path filePath)
Parse from a Path reference<T> T
parse(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
-