44 * Configuration object for the JSON parser. The configuration is immutable.
55 */
66public class JSONParserConfiguration extends ParserConfiguration {
7-
8- /** Original Configuration of the JSON Parser. */
9- public static final JSONParserConfiguration ORIGINAL = new JSONParserConfiguration ();
10-
11- /** Original configuration of the JSON Parser except that values are kept as strings. */
12- public static final JSONParserConfiguration KEEP_STRINGS = new JSONParserConfiguration ().withKeepStrings (true );
13-
147 /**
158 * Used to indicate whether to overwrite duplicate key or not.
169 */
1710 private boolean overwriteDuplicateKey ;
1811
19- /**
20- * This flag, when set to true, instructs the parser to throw a JSONException if it encounters an invalid character
21- * immediately following the final ']' character in the input. This is useful for ensuring strict adherence to the
22- * JSON syntax, as any characters after the final closing bracket of a JSON array are considered invalid.
23- */
24- private boolean strictMode ;
25-
2612 /**
2713 * Configuration with the default values.
2814 */
@@ -72,24 +58,6 @@ public JSONParserConfiguration withOverwriteDuplicateKey(final boolean overwrite
7258 return clone ;
7359 }
7460
75-
76- /**
77- * Sets the strict mode configuration for the JSON parser.
78- * <p>
79- * When strict mode is enabled, the parser will throw a JSONException if it encounters an invalid character
80- * immediately following the final ']' character in the input. This is useful for ensuring strict adherence to the
81- * JSON syntax, as any characters after the final closing bracket of a JSON array are considered invalid.
82- *
83- * @param mode a boolean value indicating whether strict mode should be enabled or not
84- * @return a new JSONParserConfiguration instance with the updated strict mode setting
85- */
86- public JSONParserConfiguration withStrictMode (final boolean mode ) {
87- JSONParserConfiguration clone = this .clone ();
88- clone .strictMode = mode ;
89-
90- return clone ;
91- }
92-
9361 /**
9462 * The parser's behavior when meeting duplicate keys, controls whether the parser should
9563 * overwrite duplicate keys or not.
@@ -99,18 +67,4 @@ public JSONParserConfiguration withStrictMode(final boolean mode) {
9967 public boolean isOverwriteDuplicateKey () {
10068 return this .overwriteDuplicateKey ;
10169 }
102-
103-
104- /**
105- * Retrieves the current strict mode setting of the JSON parser.
106- * <p>
107- * Strict mode, when enabled, instructs the parser to throw a JSONException if it encounters an invalid character
108- * immediately following the final ']' character in the input. This ensures strict adherence to the JSON syntax, as
109- * any characters after the final closing bracket of a JSON array are considered invalid.
110- *
111- * @return the current strict mode setting. True if strict mode is enabled, false otherwise.
112- */
113- public boolean isStrictMode () {
114- return this .strictMode ;
115- }
11670}
0 commit comments