@@ -141,7 +141,7 @@ public void testLongFromString(){
141
141
@ Test
142
142
public void emptyJsonObject () {
143
143
JSONObject jsonObject = new JSONObject ();
144
- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
144
+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
145
145
}
146
146
147
147
/**
@@ -184,7 +184,7 @@ public void jsonObjectByNames() {
184
184
public void jsonObjectByNullMap () {
185
185
Map <String , Object > map = null ;
186
186
JSONObject jsonObject = new JSONObject (map );
187
- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
187
+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
188
188
}
189
189
190
190
/**
@@ -1122,7 +1122,7 @@ public void bigNumberOperations() {
1122
1122
BigDecimal bigDecimal = new BigDecimal (
1123
1123
"123456789012345678901234567890.12345678901234567890123456789" );
1124
1124
jsonObject = new JSONObject (bigDecimal );
1125
- assertTrue ("large bigDecimal is not stored" , jsonObject .length () == 0 );
1125
+ assertTrue ("large bigDecimal is not stored" , jsonObject .isEmpty () );
1126
1126
1127
1127
/**
1128
1128
* JSONObject put(String, Object) method stores and serializes
@@ -2244,11 +2244,11 @@ public void jsonObjectParsingErrors() {
2244
2244
public void jsonObjectPutOnceNull () {
2245
2245
JSONObject jsonObject = new JSONObject ();
2246
2246
jsonObject .putOnce (null , null );
2247
- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2247
+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
2248
2248
jsonObject .putOnce ("" , null );
2249
- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2249
+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
2250
2250
jsonObject .putOnce (null , "" );
2251
- assertTrue ("jsonObject should be empty" , jsonObject .length () == 0 );
2251
+ assertTrue ("jsonObject should be empty" , jsonObject .isEmpty () );
2252
2252
}
2253
2253
2254
2254
/**
@@ -2424,11 +2424,11 @@ public void jsonObjectputNull() {
2424
2424
String str = "{\" myKey\" : \" myval\" }" ;
2425
2425
JSONObject jsonObjectRemove = new JSONObject (str );
2426
2426
jsonObjectRemove .remove ("myKey" );
2427
- assertEquals ("jsonObject should be empty" ,0 , jsonObjectRemove .length ());
2427
+ assertTrue ("jsonObject should be empty" , jsonObjectRemove .isEmpty ());
2428
2428
2429
2429
JSONObject jsonObjectPutNull = new JSONObject (str );
2430
2430
jsonObjectPutNull .put ("myKey" , (Object ) null );
2431
- assertEquals ("jsonObject should be empty" ,0 , jsonObjectPutNull .length ());
2431
+ assertTrue ("jsonObject should be empty" , jsonObjectPutNull .isEmpty ());
2432
2432
2433
2433
2434
2434
}
0 commit comments