Package org.json
Class JSONParserConfiguration
java.lang.Object
org.json.ParserConfiguration
org.json.JSONParserConfiguration
Configuration object for the JSON parser. The configuration is immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanUsed to indicate whether to overwrite duplicate key or not.Fields inherited from class org.json.ParserConfiguration
DEFAULT_MAXIMUM_NESTING_DEPTH, keepStrings, maxNestingDepth, UNDEFINED_MAXIMUM_NESTING_DEPTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JSONParserConfigurationclone()Provides a new instance of the same configuration.booleanThe parser's behavior when meeting duplicate keys, controls whether the parser should overwrite duplicate keys or not.withMaxNestingDepth(int maxNestingDepth) Defines the maximum nesting depth that the parser will descend before throwing an exception when parsing a map into JSONObject or parsing aCollectioninstance into JSONArray.withOverwriteDuplicateKey(boolean overwriteDuplicateKey) Controls the parser's behavior when meeting duplicate keys.Methods inherited from class org.json.ParserConfiguration
getMaxNestingDepth, isKeepStrings, withKeepStrings
-
Field Details
-
overwriteDuplicateKey
private boolean overwriteDuplicateKeyUsed to indicate whether to overwrite duplicate key or not.
-
-
Constructor Details
-
JSONParserConfiguration
public JSONParserConfiguration()Configuration with the default values.
-
-
Method Details
-
clone
Description copied from class:ParserConfigurationProvides a new instance of the same configuration.- Overrides:
clonein classParserConfiguration
-
withMaxNestingDepth
Defines the maximum nesting depth that the parser will descend before throwing an exception when parsing a map into JSONObject or parsing aCollectioninstance into JSONArray. The default max nesting depth is 512, which means the parser will throw a JsonException if the maximum depth is reached.- Overrides:
withMaxNestingDepthin classParserConfiguration- Parameters:
maxNestingDepth- the maximum nesting depth allowed to the JSON parser- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
withOverwriteDuplicateKey
Controls the parser's behavior when meeting duplicate keys. If set to false, the parser will throw a JSONException when meeting a duplicate key. Or the duplicate key's value will be overwritten.- Parameters:
overwriteDuplicateKey- defines should the parser overwrite duplicate keys.- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
isOverwriteDuplicateKey
public boolean isOverwriteDuplicateKey()The parser's behavior when meeting duplicate keys, controls whether the parser should overwrite duplicate keys or not.- Returns:
- The
overwriteDuplicateKeyconfiguration value.
-