mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-05 12:25:36 -04:00
add a test for unquoted values
This commit is contained in:
parent
a66abf22a8
commit
e41972a574
@ -51,6 +51,23 @@ public class JSONObjectTest {
|
|||||||
new JSONObject(myBean);
|
new JSONObject(myBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The JSON parser is permissive of unambiguous unquoted keys and values.
|
||||||
|
* Such JSON text should be allowed, even if it does not strictly conform
|
||||||
|
* to the spec. However, after being parsed, toString() should emit strictly
|
||||||
|
* conforming JSON text.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void unquotedText() {
|
||||||
|
String str = "{key1:value1, key2:42}";
|
||||||
|
JSONObject jsonObject = new JSONObject(str);
|
||||||
|
String textStr = jsonObject.toString();
|
||||||
|
assertTrue("expected key1", textStr.contains("\"key1\""));
|
||||||
|
assertTrue("expected value1", textStr.contains("\"value1\""));
|
||||||
|
assertTrue("expected key2", textStr.contains("\"key2\""));
|
||||||
|
assertTrue("expected 42", textStr.contains("42"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JSONObject can be created with no content
|
* A JSONObject can be created with no content
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user