@@ -141,7 +141,7 @@ public void testLongFromString(){
141141 @ Test
142142 public void emptyJsonObject () {
143143 JSONObject jsonObject = new JSONObject ();
144- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
144+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
145145 }
146146
147147 /**
@@ -184,7 +184,7 @@ public void jsonObjectByNames() {
184184 public void jsonObjectByNullMap () {
185185 Map <String , Object > map = null ;
186186 JSONObject jsonObject = new JSONObject (map );
187- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
187+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
188188 }
189189
190190 /**
@@ -1122,7 +1122,7 @@ public void bigNumberOperations() {
11221122 BigDecimal bigDecimal = new BigDecimal (
11231123 "123456789012345678901234567890.12345678901234567890123456789" );
11241124 jsonObject = new JSONObject (bigDecimal );
1125- assertTrue ("large bigDecimal is not stored" , jsonObject .length () == 0 );
1125+ assertTrue ("large bigDecimal is not stored" , jsonObject .isEmpty () );
11261126
11271127 /**
11281128 * JSONObject put(String, Object) method stores and serializes
@@ -2244,11 +2244,11 @@ public void jsonObjectParsingErrors() {
22442244 public void jsonObjectPutOnceNull () {
22452245 JSONObject jsonObject = new JSONObject ();
22462246 jsonObject .putOnce (null , null );
2247- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2247+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
22482248 jsonObject .putOnce ("" , null );
2249- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2249+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
22502250 jsonObject .putOnce (null , "" );
2251- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2251+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
22522252 }
22532253
22542254 /**
@@ -2424,11 +2424,11 @@ public void jsonObjectputNull() {
24242424 String str = "{\" myKey\" : \" myval\" }" ;
24252425 JSONObject jsonObjectRemove = new JSONObject (str );
24262426 jsonObjectRemove .remove ("myKey" );
2427- assertEquals ("jsonObject should be empty" ,0 , jsonObjectRemove .length ());
2427+ assertTrue ("jsonObject should be empty" , jsonObjectRemove .isEmpty ());
24282428
24292429 JSONObject jsonObjectPutNull = new JSONObject (str );
24302430 jsonObjectPutNull .put ("myKey" , (Object ) null );
2431- assertEquals ("jsonObject should be empty" ,0 , jsonObjectPutNull .length ());
2431+ assertTrue ("jsonObject should be empty" , jsonObjectPutNull .isEmpty ());
24322432
24332433
24342434 }
0 commit comments