@@ -94,9 +94,21 @@ public JSONArray(JSONTokener x) throws JSONException {
9494 * @throws JSONException If a syntax error occurs during the construction of the JSONArray.
9595 */
9696 public JSONArray (JSONTokener x , JSONParserConfiguration jsonParserConfiguration ) throws JSONException {
97+ this (x , jsonParserConfiguration , x .isAtStart ());
98+ }
99+
100+ /**
101+ * Constructs a JSONArray from a JSONTokener and a JSONParserConfiguration, for internal use. <br>
102+ * Never call this instead of using withStrictMode(boolean).
103+ *
104+ * @param x A JSONTokener instance from which the JSONArray is constructed.
105+ * @param jsonParserConfiguration A JSONParserConfiguration instance that controls the behavior of the parser.
106+ * @param eofRequired A boolean that determines whether this array is the root.
107+ * @throws JSONException If a syntax error occurs during the construction of the JSONArray.
108+ */
109+ JSONArray (JSONTokener x , JSONParserConfiguration jsonParserConfiguration , boolean eofRequired ) throws JSONException {
97110 this ();
98111
99- boolean isInitial = x .getPrevious () == 0 ;
100112 if (x .nextClean () != '[' ) {
101113 throw x .syntaxError ("A JSONArray text must start with '['" );
102114 }
@@ -118,10 +130,10 @@ public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration)
118130 x .back ();
119131 this .myArrayList .add (x .nextValue ());
120132 }
121- if (checkForSyntaxError (x , jsonParserConfiguration , isInitial )) return ;
133+ if (checkForSyntaxError (x , jsonParserConfiguration , eofRequired )) return ;
122134 }
123135 } else {
124- if (isInitial && jsonParserConfiguration .isStrictMode () && x .nextClean () != 0 ) {
136+ if (eofRequired && jsonParserConfiguration .isStrictMode () && x .nextClean () != 0 ) {
125137 throw x .syntaxError ("Strict mode error: Unparsed characters found at end of input text" );
126138 }
127139 }
0 commit comments