Skip to content

Commit 527b90a

Browse files
committed
added parseToJSONArray and parseToJSONObject functions
1 parent a597ee3 commit 527b90a

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/main/java/org/json/simple/parser/JSONParser.java

+33-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public Object parse(String s) throws ParseException {
9494
/**
9595
* Parse JSON Text into JSONObject from the input source, continuously reading until
9696
* the end of the string
97+
* @author Aurangzeb <[email protected]>
9798
*
9899
* @param in
99100
*
@@ -110,6 +111,7 @@ public JSONObject parseToJSONObject( String s ) throws ParseException {
110111
/**
111112
* Parse JSON Text into JSONObject from the input source, continuously reading until
112113
* the end of the string
114+
* @author Aurangzeb <[email protected]>
113115
*
114116
* @param in
115117
*
@@ -139,7 +141,7 @@ public void parse(String s, ContentHandler handler) throws ParseException {
139141
throw new ParseException(-1, ParseException.ERROR_UNEXPECTED_EXCEPTION, ie);
140142
}
141143
}
142-
144+
143145
/**
144146
* Parse JSON text into java object from the input source. Reads
145147
* until end of the next JSON object, array, or value
@@ -157,6 +159,36 @@ public Object parse(Reader in) throws IOException, ParseException {
157159
parse(in, handler);
158160
return handler.getContent();
159161
}
162+
163+
/**
164+
* Parse JSON text into java object from the input source. Reads
165+
* until end of the next JSON object, array, or value
166+
* @author Aurangzeb <[email protected]>
167+
*
168+
* @param in
169+
* @return Instance of the following: org.json.simple.JSONObject
170+
*
171+
* @throws IOException
172+
* @throws ParseException
173+
*/
174+
public JSONObject parseToJSONObject( Reader in ) throws IOException, ParseException {
175+
return (JSONObject) this.parse(in);
176+
}
177+
178+
/**
179+
* Parse JSON text into java object from the input source. Reads
180+
* until end of the next JSON object, array, or value
181+
* @author Aurangzeb <[email protected]>
182+
*
183+
* @param in
184+
* @return Instance of the following: org.json.simple.JSONArray
185+
*
186+
* @throws IOException
187+
* @throws ParseException
188+
*/
189+
public JSONArray parseToJSONArray( Reader in ) throws IOException, ParseException {
190+
return (JSONArray) this.parse(in);
191+
}
160192

161193
/**
162194
* Parse JSON text into java object from the input source.

0 commit comments

Comments
 (0)