@@ -412,48 +412,45 @@ public String nextTo(String delimiters) throws JSONException {
412412 * @throws JSONException If syntax error.
413413 */
414414 public Object nextValue () throws JSONException {
415- return nextValue (false );
415+ return nextValue (new JSONParserConfiguration () );
416416 }
417417
418418 /**
419419 * Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
420420 * JSONObject.NULL object. The strictMode parameter controls the behavior of the method when parsing the value.
421421 *
422- * @param strictMode If true, the method will strictly adhere to the JSON syntax, throwing a JSONException for any
423- * deviations.
422+ * @param jsonParserConfiguration which carries options such as strictMode and allowSingleQuotes, these methods will
423+ * strictly adhere to the JSON syntax, throwing a JSONException for any deviations.
424424 * @return An object.
425425 * @throws JSONException If syntax error.
426426 */
427- public Object nextValue (boolean strictMode ) throws JSONException {
427+ public Object nextValue (JSONParserConfiguration jsonParserConfiguration ) throws JSONException {
428428 char c = this .nextClean ();
429429 switch (c ) {
430430 case '{' :
431431 this .back ();
432- return getJsonObject (strictMode );
432+ return getJsonObject (jsonParserConfiguration );
433433 case '[' :
434434 this .back ();
435435 return getJsonArray ();
436436 default :
437- return nextSimpleValue (c , strictMode );
437+ return nextSimpleValue (c , jsonParserConfiguration );
438438 }
439439 }
440440
441441 /**
442442 * This method is used to get a JSONObject from the JSONTokener. The strictMode parameter controls the behavior of
443443 * the method when parsing the JSONObject.
444444 *
445- * @param strictMode If true, the method will strictly adhere to the JSON syntax, throwing a JSONException for any
446- * deviations.
445+ * @param jsonParserConfiguration which carries options such as strictMode and allowSingleQuotes, these methods will
446+ * strictly adhere to the JSON syntax, throwing a JSONException for any deviations.
447+ * deviations.
447448 * @return A JSONObject which is the next value in the JSONTokener.
448449 * @throws JSONException If the JSONObject or JSONArray depth is too large to process.
449450 */
450- private JSONObject getJsonObject (boolean strictMode ) {
451+ private JSONObject getJsonObject (JSONParserConfiguration jsonParserConfiguration ) {
451452 try {
452- if (strictMode ) {
453- return new JSONObject (this , new JSONParserConfiguration ().withStrictMode (true ));
454- }
455-
456- return new JSONObject (this );
453+ return new JSONObject (this , jsonParserConfiguration );
457454 } catch (StackOverflowError e ) {
458455 throw new JSONException ("JSON Array or Object depth too large to process." , e );
459456 }
@@ -473,7 +470,14 @@ private JSONArray getJsonArray() {
473470 }
474471 }
475472
476- Object nextSimpleValue (char c , boolean strictMode ) {
473+ Object nextSimpleValue (char c , JSONParserConfiguration jsonParserConfiguration ) {
474+ boolean strictMode = jsonParserConfiguration .isStrictMode ();
475+ boolean allowSingleQuotes = jsonParserConfiguration .isAllowSingleQuotes ();
476+
477+ if (strictMode && !allowSingleQuotes && c == '\'' ){
478+ throw this .syntaxError ("Single quote wrap not allowed in strict mode" );
479+ }
480+
477481 if (c == '"' || c == '\'' ) {
478482 return this .nextString (c , strictMode );
479483 }
0 commit comments