mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Merge pull request #66 from stleary/document-unquoted-strings
add a test for unquoted values
This commit is contained in:
commit
82ff14ed8d
1 changed files with 17 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue