File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/test/java/org/json/junit Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,23 @@ public void jsonObjectByNullBean() {
5151 new JSONObject (myBean );
5252 }
5353
54+ /**
55+ * The JSON parser is permissive of unambiguous unquoted keys and values.
56+ * Such JSON text should be allowed, even if it does not strictly conform
57+ * to the spec. However, after being parsed, toString() should emit strictly
58+ * conforming JSON text.
59+ */
60+ @ Test
61+ public void unquotedText () {
62+ String str = "{key1:value1, key2:42}" ;
63+ JSONObject jsonObject = new JSONObject (str );
64+ String textStr = jsonObject .toString ();
65+ assertTrue ("expected key1" , textStr .contains ("\" key1\" " ));
66+ assertTrue ("expected value1" , textStr .contains ("\" value1\" " ));
67+ assertTrue ("expected key2" , textStr .contains ("\" key2\" " ));
68+ assertTrue ("expected 42" , textStr .contains ("42" ));
69+ }
70+
5471 /**
5572 * A JSONObject can be created with no content
5673 */
You can’t perform that action at this time.
0 commit comments