Adding JSONParserConfiguration for configuring the depth of nested maps

This commit is contained in:
sk02241994
2023-12-22 15:44:33 +05:30
parent dcac3bc18e
commit abea194120
5 changed files with 115 additions and 34 deletions

View File

@@ -0,0 +1,29 @@
package org.json;
/**
* Configuration object for the JSON parser. The configuration is immutable.
*/
public class JSONParserConfiguration extends ParserConfiguration {
/**
* We can override the default maximum nesting depth if needed.
*/
public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = ParserConfiguration.DEFAULT_MAXIMUM_NESTING_DEPTH;
/**
* Configuration with the default values.
*/
public JSONParserConfiguration() {
this.maxNestingDepth = DEFAULT_MAXIMUM_NESTING_DEPTH;
}
public JSONParserConfiguration(int maxNestingDepth) {
this.maxNestingDepth = maxNestingDepth;
}
@Override
protected JSONParserConfiguration clone() {
return new JSONParserConfiguration(DEFAULT_MAXIMUM_NESTING_DEPTH);
}
}