@@ -40,7 +40,7 @@ of this software and associated documentation files (the "Software"), to deal
40
40
* comparisons of .toString to a string literal are likely to fail.
41
41
*
42
42
* @author JSON.org
43
- * @version 2011-05-22
43
+ * @version 2011-10-03
44
44
*/
45
45
public class Test extends TestCase {
46
46
public Test (String name ) {
@@ -91,7 +91,11 @@ public void testJSON() throws Exception {
91
91
92
92
Beany beanie = new Beany ("A beany object" , 42 , true );
93
93
94
- string = "[0.1]" ;
94
+ string = "[001122334455]" ;
95
+ jsonarray = new JSONArray (string );
96
+ assertEquals ("[1122334455]" , jsonarray .toString ());
97
+
98
+ string = "[00.10]" ;
95
99
jsonarray = new JSONArray (string );
96
100
assertEquals ("[0.1]" , jsonarray .toString ());
97
101
@@ -154,16 +158,17 @@ public void testJSON() throws Exception {
154
158
jsonarray .toString (4 ));
155
159
assertEquals ("<div id=\" demo\" class=\" JSONML\" ><p>JSONML is a transformation between<b>JSON</b>and<b>XML</b>that preserves ordering of document features.</p><p>JSONML can work with JSON arrays or JSON objects.</p><p>Three<br/>little<br/>words</p></div>" ,
156
160
JSONML .toString (jsonarray ));
161
+
162
+ string = "{\" xmlns:soap\" :\" http://www.w3.org/2003/05/soap-envelope\" ,\" tagName\" :\" soap:Envelope\" ,\" childNodes\" :[{\" tagName\" :\" soap:Header\" },{\" tagName\" :\" soap:Body\" ,\" childNodes\" :[{\" tagName\" :\" ws:listProducts\" ,\" childNodes\" :[{\" tagName\" :\" ws:delay\" ,\" childNodes\" :[1]}]}]}],\" xmlns:ws\" :\" http://warehouse.acme.com/ws\" }" ;
163
+ jsonobject = new JSONObject (string );
164
+ assertEquals ("<soap:Envelope xmlns:soap=\" http://www.w3.org/2003/05/soap-envelope\" xmlns:ws=\" http://warehouse.acme.com/ws\" ><soap:Header/><soap:Body><ws:listProducts><ws:delay>1</ws:delay></ws:listProducts></soap:Body></soap:Envelope>" ,
165
+ JSONML .toString (jsonobject ));
157
166
158
167
string = "<person created=\" 2006-11-11T19:23\" modified=\" 2006-12-31T23:59\" >\n <firstName>Robert</firstName>\n <lastName>Smith</lastName>\n <address type=\" home\" >\n <street>12345 Sixth Ave</street>\n <city>Anytown</city>\n <state>CA</state>\n <postalCode>98765-4321</postalCode>\n </address>\n </person>" ;
159
168
jsonobject = XML .toJSONObject (string );
160
169
assertEquals ("{\" person\" : {\n \" lastName\" : \" Smith\" ,\n \" address\" : {\n \" postalCode\" : \" 98765-4321\" ,\n \" street\" : \" 12345 Sixth Ave\" ,\n \" state\" : \" CA\" ,\n \" type\" : \" home\" ,\n \" city\" : \" Anytown\" \n },\n \" created\" : \" 2006-11-11T19:23\" ,\n \" firstName\" : \" Robert\" ,\n \" modified\" : \" 2006-12-31T23:59\" \n }}" ,
161
170
jsonobject .toString (4 ));
162
171
163
- jsonobject = new JSONObject (beanie );
164
- assertEquals ("{\" string\" :\" A beany object\" ,\" BENT\" :\" All uppercase key\" ,\" boolean\" :true,\" number\" :42,\" x\" :\" x\" }"
165
- , jsonobject .toString ());
166
-
167
172
string = "{ \" entity\" : { \" imageURL\" : \" \" , \" name\" : \" IXXXXXXXXXXXXX\" , \" id\" : 12336, \" ratingCount\" : null, \" averageRating\" : null } }" ;
168
173
jsonobject = new JSONObject (string );
169
174
assertEquals ("{\" entity\" : {\n \" id\" : 12336,\n \" averageRating\" : null,\n \" ratingCount\" : null,\n \" name\" : \" IXXXXXXXXXXXXX\" ,\n \" imageURL\" : \" \" \n }}" ,
0 commit comments