mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 03:06:03 +08:00
24 lines
613 B
Java
24 lines
613 B
Java
package org.json.junit;
|
|
|
|
import org.json.*;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class JSONObjectDuplicateKeyTest {
|
|
private static final String TEST_SOURCE = "{\"key\": \"value1\", \"key\": \"value2\"}";
|
|
|
|
@Test(expected = JSONException.class)
|
|
public void testThrowException() {
|
|
new JSONObject(TEST_SOURCE);
|
|
}
|
|
|
|
@Test
|
|
public void testOverwrite() {
|
|
JSONObject jsonObject = new JSONObject(TEST_SOURCE, new JSONParserConfiguration(true));
|
|
|
|
assertEquals("duplicate key should be overwritten", "value2", jsonObject.getString("key"));
|
|
}
|
|
}
|