@@ -75,31 +75,19 @@ public JSONArray() {
7575 }
7676
7777 /**
78- * Constructs a JSONArray from a JSONTokener.
79- * <p>
80- * This constructor reads the JSONTokener to parse a JSON array. It uses the default JSONParserConfiguration.
78+ * Construct a JSONArray from a JSONTokener.
8179 *
82- * @param x A JSONTokener
83- * @throws JSONException If there is a syntax error.
80+ * @param x
81+ * A JSONTokener
82+ * @throws JSONException
83+ * If there is a syntax error.
8484 */
8585 public JSONArray (JSONTokener x ) throws JSONException {
86- this (x , new JSONParserConfiguration ());
87- }
88-
89- /**
90- * Constructs a JSONArray from a JSONTokener and a JSONParserConfiguration.
91- * JSONParserConfiguration contains strictMode turned off (false) by default.
92- *
93- * @param x A JSONTokener instance from which the JSONArray is constructed.
94- * @param jsonParserConfiguration A JSONParserConfiguration instance that controls the behavior of the parser.
95- * @throws JSONException If a syntax error occurs during the construction of the JSONArray.
96- */
97- public JSONArray (JSONTokener x , JSONParserConfiguration jsonParserConfiguration ) throws JSONException {
9886 this ();
9987 if (x .nextClean () != '[' ) {
10088 throw x .syntaxError ("A JSONArray text must start with '['" );
10189 }
102-
90+
10391 char nextChar = x .nextClean ();
10492 if (nextChar == 0 ) {
10593 // array is unclosed. No ']' found, instead EOF
@@ -113,34 +101,27 @@ public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration)
113101 this .myArrayList .add (JSONObject .NULL );
114102 } else {
115103 x .back ();
116- this .myArrayList .add (x .nextValue (jsonParserConfiguration ));
104+ this .myArrayList .add (x .nextValue ());
117105 }
118106 switch (x .nextClean ()) {
119- case 0 :
107+ case 0 :
108+ // array is unclosed. No ']' found, instead EOF
109+ throw x .syntaxError ("Expected a ',' or ']'" );
110+ case ',' :
111+ nextChar = x .nextClean ();
112+ if (nextChar == 0 ) {
120113 // array is unclosed. No ']' found, instead EOF
121114 throw x .syntaxError ("Expected a ',' or ']'" );
122- case ',' :
123- nextChar = x .nextClean ();
124- if (nextChar == 0 ) {
125- // array is unclosed. No ']' found, instead EOF
126- throw x .syntaxError ("Expected a ',' or ']'" );
127- }
128- if (nextChar == ']' ) {
129- return ;
130- }
131- x .back ();
132- break ;
133- case ']' :
134- if (jsonParserConfiguration .isStrictMode ()) {
135- nextChar = x .nextClean ();
136- if (nextChar != 0 ) {
137- throw x .syntaxError ("invalid character found after end of array: " + nextChar );
138- }
139- }
140-
115+ }
116+ if (nextChar == ']' ) {
141117 return ;
142- default :
143- throw x .syntaxError ("Expected a ',' or ']'" );
118+ }
119+ x .back ();
120+ break ;
121+ case ']' :
122+ return ;
123+ default :
124+ throw x .syntaxError ("Expected a ',' or ']'" );
144125 }
145126 }
146127 }
@@ -157,19 +138,7 @@ public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration)
157138 * If there is a syntax error.
158139 */
159140 public JSONArray (String source ) throws JSONException {
160- this (new JSONTokener (source ), new JSONParserConfiguration ());
161- }
162-
163- /**
164- * Constructs a JSONArray from a source JSON text and a JSONParserConfiguration.
165- *
166- * @param source A string that begins with <code>[</code> <small>(left bracket)</small> and
167- * ends with <code>]</code> <small>(right bracket)</small>.
168- * @param jsonParserConfiguration A JSONParserConfiguration instance that controls the behavior of the parser.
169- * @throws JSONException If there is a syntax error.
170- */
171- public JSONArray (String source , JSONParserConfiguration jsonParserConfiguration ) throws JSONException {
172- this (new JSONTokener (source ), jsonParserConfiguration );
141+ this (new JSONTokener (source ));
173142 }
174143
175144 /**
@@ -398,7 +367,7 @@ public Number getNumber(int index) throws JSONException {
398367
399368 /**
400369 * Get the enum value associated with an index.
401- *
370+ *
402371 * @param <E>
403372 * Enum Type
404373 * @param clazz
@@ -586,7 +555,7 @@ public String join(String separator) throws JSONException {
586555 if (len == 0 ) {
587556 return "" ;
588557 }
589-
558+
590559 StringBuilder sb = new StringBuilder (
591560 JSONObject .valueToString (this .myArrayList .get (0 )));
592561
@@ -900,7 +869,7 @@ public Integer optIntegerObject(int index, Integer defaultValue) {
900869
901870 /**
902871 * Get the enum value associated with a key.
903- *
872+ *
904873 * @param <E>
905874 * Enum Type
906875 * @param clazz
@@ -915,7 +884,7 @@ public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) {
915884
916885 /**
917886 * Get the enum value associated with a key.
918- *
887+ *
919888 * @param <E>
920889 * Enum Type
921890 * @param clazz
@@ -948,8 +917,8 @@ public <E extends Enum<E>> E optEnum(Class<E> clazz, int index, E defaultValue)
948917 }
949918
950919 /**
951- * Get the optional BigInteger value associated with an index. The
952- * defaultValue is returned if there is no value for the index, or if the
920+ * Get the optional BigInteger value associated with an index. The
921+ * defaultValue is returned if there is no value for the index, or if the
953922 * value is not a number and cannot be converted to a number.
954923 *
955924 * @param index
@@ -964,8 +933,8 @@ public BigInteger optBigInteger(int index, BigInteger defaultValue) {
964933 }
965934
966935 /**
967- * Get the optional BigDecimal value associated with an index. The
968- * defaultValue is returned if there is no value for the index, or if the
936+ * Get the optional BigDecimal value associated with an index. The
937+ * defaultValue is returned if there is no value for the index, or if the
969938 * value is not a number and cannot be converted to a number. If the value
970939 * is float or double, the {@link BigDecimal#BigDecimal(double)}
971940 * constructor will be used. See notes on the constructor for conversion
@@ -1134,7 +1103,7 @@ public Number optNumber(int index, Number defaultValue) {
11341103 if (val instanceof Number ){
11351104 return (Number ) val ;
11361105 }
1137-
1106+
11381107 if (val instanceof String ) {
11391108 try {
11401109 return JSONObject .stringToNumber ((String ) val );
@@ -1211,7 +1180,7 @@ public JSONArray put(Collection<?> value) {
12111180 public JSONArray put (double value ) throws JSONException {
12121181 return this .put (Double .valueOf (value ));
12131182 }
1214-
1183+
12151184 /**
12161185 * Append a float value. This increases the array's length by one.
12171186 *
@@ -1466,19 +1435,19 @@ public JSONArray put(int index, Object value) throws JSONException {
14661435 *
14671436 * @param collection
14681437 * A Collection.
1469- * @return this.
1438+ * @return this.
14701439 */
14711440 public JSONArray putAll (Collection <?> collection ) {
14721441 this .addAll (collection , false );
14731442 return this ;
14741443 }
1475-
1444+
14761445 /**
14771446 * Put an Iterable's elements in to the JSONArray.
14781447 *
14791448 * @param iter
14801449 * An Iterable.
1481- * @return this.
1450+ * @return this.
14821451 */
14831452 public JSONArray putAll (Iterable <?> iter ) {
14841453 this .addAll (iter , false );
@@ -1490,7 +1459,7 @@ public JSONArray putAll(Iterable<?> iter) {
14901459 *
14911460 * @param array
14921461 * A JSONArray.
1493- * @return this.
1462+ * @return this.
14941463 */
14951464 public JSONArray putAll (JSONArray array ) {
14961465 // directly copy the elements from the source array to this one
@@ -1505,7 +1474,7 @@ public JSONArray putAll(JSONArray array) {
15051474 * @param array
15061475 * Array. If the parameter passed is null, or not an array or Iterable, an
15071476 * exception will be thrown.
1508- * @return this.
1477+ * @return this.
15091478 *
15101479 * @throws JSONException
15111480 * If not an array, JSONArray, Iterable or if an value is non-finite number.
@@ -1516,17 +1485,17 @@ public JSONArray putAll(Object array) throws JSONException {
15161485 this .addAll (array , false );
15171486 return this ;
15181487 }
1519-
1488+
15201489 /**
1521- * Creates a JSONPointer using an initialization string and tries to
1490+ * Creates a JSONPointer using an initialization string and tries to
15221491 * match it to an item within this JSONArray. For example, given a
15231492 * JSONArray initialized with this document:
15241493 * <pre>
15251494 * [
15261495 * {"b":"c"}
15271496 * ]
15281497 * </pre>
1529- * and this JSONPointer string:
1498+ * and this JSONPointer string:
15301499 * <pre>
15311500 * "/0/b"
15321501 * </pre>
@@ -1539,17 +1508,17 @@ public JSONArray putAll(Object array) throws JSONException {
15391508 public Object query (String jsonPointer ) {
15401509 return query (new JSONPointer (jsonPointer ));
15411510 }
1542-
1511+
15431512 /**
1544- * Uses a user initialized JSONPointer and tries to
1513+ * Uses a user initialized JSONPointer and tries to
15451514 * match it to an item within this JSONArray. For example, given a
15461515 * JSONArray initialized with this document:
15471516 * <pre>
15481517 * [
15491518 * {"b":"c"}
15501519 * ]
15511520 * </pre>
1552- * and this JSONPointer:
1521+ * and this JSONPointer:
15531522 * <pre>
15541523 * "/0/b"
15551524 * </pre>
@@ -1562,23 +1531,23 @@ public Object query(String jsonPointer) {
15621531 public Object query (JSONPointer jsonPointer ) {
15631532 return jsonPointer .queryFrom (this );
15641533 }
1565-
1534+
15661535 /**
15671536 * Queries and returns a value from this object using {@code jsonPointer}, or
15681537 * returns null if the query fails due to a missing key.
1569- *
1538+ *
15701539 * @param jsonPointer the string representation of the JSON pointer
15711540 * @return the queried value or {@code null}
15721541 * @throws IllegalArgumentException if {@code jsonPointer} has invalid syntax
15731542 */
15741543 public Object optQuery (String jsonPointer ) {
15751544 return optQuery (new JSONPointer (jsonPointer ));
15761545 }
1577-
1546+
15781547 /**
15791548 * Queries and returns a value from this object using {@code jsonPointer}, or
15801549 * returns null if the query fails due to a missing key.
1581- *
1550+ *
15821551 * @param jsonPointer The JSON pointer
15831552 * @return the queried value or {@code null}
15841553 * @throws IllegalArgumentException if {@code jsonPointer} has invalid syntax
@@ -1698,11 +1667,11 @@ public String toString() {
16981667
16991668 /**
17001669 * Make a pretty-printed JSON text of this JSONArray.
1701- *
1670+ *
17021671 * <p>If <pre> {@code indentFactor > 0}</pre> and the {@link JSONArray} has only
17031672 * one element, then the array will be output on a single line:
17041673 * <pre>{@code [1]}</pre>
1705- *
1674+ *
17061675 * <p>If an array has 2 or more elements, then it will be output across
17071676 * multiple lines: <pre>{@code
17081677 * [
@@ -1714,7 +1683,7 @@ public String toString() {
17141683 * <p><b>
17151684 * Warning: This method assumes that the data structure is acyclical.
17161685 * </b>
1717- *
1686+ *
17181687 * @param indentFactor
17191688 * The number of spaces to add to each level of indentation.
17201689 * @return a printable, displayable, transmittable representation of the
@@ -1748,11 +1717,11 @@ public Writer write(Writer writer) throws JSONException {
17481717
17491718 /**
17501719 * Write the contents of the JSONArray as JSON text to a writer.
1751- *
1720+ *
17521721 * <p>If <pre>{@code indentFactor > 0}</pre> and the {@link JSONArray} has only
17531722 * one element, then the array will be output on a single line:
17541723 * <pre>{@code [1]}</pre>
1755- *
1724+ *
17561725 * <p>If an array has 2 or more elements, then it will be output across
17571726 * multiple lines: <pre>{@code
17581727 * [
@@ -1978,7 +1947,7 @@ private void addAll(Object array, boolean wrap, int recursionDepth, JSONParserCo
19781947 "JSONArray initial value should be a string or collection or array." );
19791948 }
19801949 }
1981-
1950+
19821951 /**
19831952 * Create a new JSONException in a common format for incorrect conversions.
19841953 * @param idx index of the item
0 commit comments