Source:
public void jsonObjectByBean3() { JSONObject jsonObject = new JSONObject(new MyBeanCustomNameSubClass()); assertNotNull(jsonObject); assertEquals("Wrong number of keys found:", 7, jsonObject.keySet().size()); assertFalse("Normal int field name (someInt) found, but was overridden", jsonObject.has("someInt")); assertFalse("Normal field name (myDouble) processing did not work", jsonObject.has("myDouble")); assertFalse("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) not FOUND!", jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!")); assertFalse("Normal field name (someFloat) found, but was overridden", jsonObject.has("someFloat")); assertFalse("Ignored field found! but was overridden", jsonObject.has("ignoredInt")); assertFalse("Ignored field at the same level as forced name not found", jsonObject.has("ShouldBeIgnored")); assertFalse("Normally ignored field (able) with explicit property name not found", jsonObject.has("able")); assertTrue("Overridden int field name (newIntFieldName) found", jsonObject.has("newIntFieldName")); assertTrue("Normal field name (someLong) found", jsonObject.has("someLong")); assertTrue("Overridden String field name (myStringField) found", jsonObject.has("myStringField")); assertTrue("Overridden double field name (AMoreNormalName) found", jsonObject.has("AMoreNormalName")); assertTrue("Overridden String field name (InterfaceField) found", jsonObject.has("InterfaceField")); assertTrue("Forced field found!", jsonObject.has("forcedInt")); assertTrue("Overridden boolean field name (Getable) found", jsonObject.has("Getable")); }

Target:
public void jsonObjectByBean3() { JSONObject jsonObject = new JSONObject(new MyBeanCustomNameSubClass()); assertNotNull(jsonObject); assertEquals("Wrong number of keys found:", 7, jsonObject.keySet().size()); assertFalse("Normal int field name (someInt) found, but was overridden", jsonObject.has("someInt")); assertFalse("Normal field name (myDouble) processing did not work", jsonObject.has("myDouble")); assertFalse("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) should not be FOUND!", jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!")); assertFalse("Normal field name (someFloat) found, but was overridden", jsonObject.has("someFloat")); assertFalse("Ignored field found! but was overridden", jsonObject.has("ignoredInt")); assertFalse("Ignored field at the same level as forced name should not have been found", jsonObject.has("ShouldBeIgnored")); assertFalse("Normally ignored field (able) with explicit property name should not have been found", jsonObject.has("able")); assertTrue("Overridden int field name (newIntFieldName) should have been found", jsonObject.has("newIntFieldName")); assertTrue("Normal field name (someLong) should have been found", jsonObject.has("someLong")); assertTrue("Overridden String field name (myStringField) should have been found", jsonObject.has("myStringField")); assertTrue("Overridden double field name (AMoreNormalName) should have been found", jsonObject.has("AMoreNormalName")); assertTrue("Overridden String field name (InterfaceField) should have been found", jsonObject.has("InterfaceField")); assertTrue("Forced field should have been found!", jsonObject.has("forcedInt")); assertTrue("Overridden boolean field name (Getable) should have been found", jsonObject.has("Getable")); }