mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-25 00:00:38 -05:00
Revert "Merge pull request #877 from rikkarth/feat/871-strictMode"
This reverts commitd02ac0f2a3, reversing changes made tocfd47615d0.
This commit is contained in:
@@ -4,25 +4,11 @@ package org.json;
|
||||
* Configuration object for the JSON parser. The configuration is immutable.
|
||||
*/
|
||||
public class JSONParserConfiguration extends ParserConfiguration {
|
||||
|
||||
/** Original Configuration of the JSON Parser. */
|
||||
public static final JSONParserConfiguration ORIGINAL = new JSONParserConfiguration();
|
||||
|
||||
/** Original configuration of the JSON Parser except that values are kept as strings. */
|
||||
public static final JSONParserConfiguration KEEP_STRINGS = new JSONParserConfiguration().withKeepStrings(true);
|
||||
|
||||
/**
|
||||
* Used to indicate whether to overwrite duplicate key or not.
|
||||
*/
|
||||
private boolean overwriteDuplicateKey;
|
||||
|
||||
/**
|
||||
* This flag, when set to true, instructs the parser to throw a JSONException if it encounters an invalid character
|
||||
* immediately following the final ']' character in the input. This is useful for ensuring strict adherence to the
|
||||
* JSON syntax, as any characters after the final closing bracket of a JSON array are considered invalid.
|
||||
*/
|
||||
private boolean strictMode;
|
||||
|
||||
/**
|
||||
* Configuration with the default values.
|
||||
*/
|
||||
@@ -72,24 +58,6 @@ public class JSONParserConfiguration extends ParserConfiguration {
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the strict mode configuration for the JSON parser.
|
||||
* <p>
|
||||
* When strict mode is enabled, the parser will throw a JSONException if it encounters an invalid character
|
||||
* immediately following the final ']' character in the input. This is useful for ensuring strict adherence to the
|
||||
* JSON syntax, as any characters after the final closing bracket of a JSON array are considered invalid.
|
||||
*
|
||||
* @param mode a boolean value indicating whether strict mode should be enabled or not
|
||||
* @return a new JSONParserConfiguration instance with the updated strict mode setting
|
||||
*/
|
||||
public JSONParserConfiguration withStrictMode(final boolean mode) {
|
||||
JSONParserConfiguration clone = this.clone();
|
||||
clone.strictMode = mode;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parser's behavior when meeting duplicate keys, controls whether the parser should
|
||||
* overwrite duplicate keys or not.
|
||||
@@ -99,18 +67,4 @@ public class JSONParserConfiguration extends ParserConfiguration {
|
||||
public boolean isOverwriteDuplicateKey() {
|
||||
return this.overwriteDuplicateKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the current strict mode setting of the JSON parser.
|
||||
* <p>
|
||||
* Strict mode, when enabled, instructs the parser to throw a JSONException if it encounters an invalid character
|
||||
* immediately following the final ']' character in the input. This ensures strict adherence to the JSON syntax, as
|
||||
* any characters after the final closing bracket of a JSON array are considered invalid.
|
||||
*
|
||||
* @return the current strict mode setting. True if strict mode is enabled, false otherwise.
|
||||
*/
|
||||
public boolean isStrictMode() {
|
||||
return this.strictMode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user