Package flexjson.transformer

Examples of flexjson.transformer.BooleanAsStringTransformer


        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 );
View Full Code Here

TOP

Related Classes of flexjson.transformer.BooleanAsStringTransformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.