Skip to content

Commit 48c092a

Browse files
authored
Merge pull request stleary#876 from stleary/remove-jsonparserconfig-ctor
remove-jsonparserconfig-ctor - just use withOverwriteDuplicateKey()
2 parents 712859d + dab29ec commit 48c092a

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/main/java/org/json/JSONParserConfiguration.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,14 @@ public class JSONParserConfiguration extends ParserConfiguration {
1313
* Configuration with the default values.
1414
*/
1515
public JSONParserConfiguration() {
16-
this(false);
17-
}
18-
19-
/**
20-
* Configure the parser with argument overwriteDuplicateKey.
21-
*
22-
* @param overwriteDuplicateKey Indicate whether to overwrite duplicate key or not.<br>
23-
* If not, the JSONParser will throw a {@link JSONException}
24-
* when meeting duplicate keys.
25-
*/
26-
public JSONParserConfiguration(boolean overwriteDuplicateKey) {
2716
super();
28-
this.overwriteDuplicateKey = overwriteDuplicateKey;
17+
this.overwriteDuplicateKey = false;
2918
}
3019

3120
@Override
3221
protected JSONParserConfiguration clone() {
33-
JSONParserConfiguration clone = new JSONParserConfiguration(overwriteDuplicateKey);
22+
JSONParserConfiguration clone = new JSONParserConfiguration();
23+
clone.overwriteDuplicateKey = overwriteDuplicateKey;
3424
clone.maxNestingDepth = maxNestingDepth;
3525
return clone;
3626
}

src/test/java/org/json/junit/JSONParserConfigurationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public void testThrowException() {
1818

1919
@Test
2020
public void testOverwrite() {
21-
JSONObject jsonObject = new JSONObject(TEST_SOURCE, new JSONParserConfiguration(true));
21+
JSONObject jsonObject = new JSONObject(TEST_SOURCE,
22+
new JSONParserConfiguration().withOverwriteDuplicateKey(true));
2223

2324
assertEquals("duplicate key should be overwritten", "value2", jsonObject.getString("key"));
2425
}

0 commit comments

Comments
 (0)