assertEquals( "Ben", jsonP[2].getFirstname() );
}
@Test
public void testDeserializeIntoExistingObject() {
Person charlie = creator.createCharlie();
Phone fakePhone = new Phone( PhoneNumberType.MOBILE, "303 555 1234");
Person charlieClone = new Person( "Chauncy", "Beauregard", null, null, null );
charlieClone.getPhones().add( fakePhone );
charlieClone.getHobbies().add("Being Fake");
charlieClone.getHobbies().add("Assuming Other Identities");
String json = new JSONSerializer().include("hobbies").exclude("firstname", "lastname").serialize( charlie );
Person p = new JSONDeserializer<Person>().deserializeInto(json, charlieClone);
assertSame("Make sure the root object is the exact same reference as the one provided to the factory", charlieClone, p );
assertEquals( charlieClone.getFirstname(), p.getFirstname() );
assertEquals( charlieClone.getLastname(), p.getLastname() );
assertEquals( charlie.getBirthdate(), p.getBirthdate() );
assertEquals( charlie.getFirstBaseBallGame(), p.getFirstBaseBallGame() );
assertEquals( charlie.getWork(), p.getWork() );
assertEquals( charlie.getWork().getZipcode(), p.getWork().getZipcode() );
assertEquals( charlie.getHome(), p.getHome() );
assertEquals( charlie.getHobbies().size(), p.getHobbies().size() );
assertEquals( 1, p.getPhones().size() );
assertEquals( 2, charlie.getPhones().size() );
assertSame( fakePhone, p.getPhones().get(0) );
}