Code review action items - add comments and consistent error messages for strict mode

This commit is contained in:
Sean Leary
2024-12-21 09:50:52 -06:00
parent d3c7eaf17e
commit 2dcef89a6f
7 changed files with 77 additions and 49 deletions

View File

@@ -64,6 +64,18 @@ public class JSONParserConfiguration extends ParserConfiguration {
return clone;
}
/**
* Sets the strict mode configuration for the JSON parser with default true value
* <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.
* @return a new JSONParserConfiguration instance with the updated strict mode setting
*/
public JSONParserConfiguration withStrictMode() {
return withStrictMode(true);
}
/**
* Sets the strict mode configuration for the JSON parser.
* <p>
@@ -92,13 +104,7 @@ public class JSONParserConfiguration extends ParserConfiguration {
}
/**
* 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.
* @return the current strict mode setting.
*/
public boolean isStrictMode() {
return this.strictMode;