String expectedYes = "{\"class\":\"flexjson.mock.Spiderman\",\"spideySense\":\"yes\",\"superpower\":\"Creates web\"}";
String expectedNo = "{\"class\":\"flexjson.mock.Spiderman\",\"spideySense\":\"no\",\"superpower\":\"Creates web\"}";
Spiderman spiderman = new Spiderman();
spiderman.spideySense = true;
String json = new JSONSerializer().transform( new BooleanAsStringTransformer("yes", "no"), Boolean.class ).serialize(spiderman);
assertEquals( expectedYes, json );
spiderman.spideySense = false;
json = new JSONSerializer().transform( new BooleanAsStringTransformer("yes", "no"), Boolean.class ).serialize(spiderman);
assertEquals( expectedNo, json );
spiderman = new JSONDeserializer<Spiderman>().use(Boolean.class, new BooleanAsStringObjectFactory("yes", "no")).deserialize(expectedYes, Spiderman.class);
assertTrue( "Assert it deserialized yes into true", spiderman.spideySense );
spiderman = new JSONDeserializer<Spiderman>().use(Boolean.class, new BooleanAsStringObjectFactory("yes", "no")).deserialize( expectedNo, Spiderman.class );