Package org.baeldung.gson.serialization

Examples of org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer


    @Test
    public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored() {
        final SourceClass sourceObject = new SourceClass(-1, "minus 1");
        final GsonBuilder gsonBuildr = new GsonBuilder();
        gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer());
        final Gson gson = gsonBuildr.create();
        final Type sourceObjectType = new TypeToken<SourceClass>() {
        }.getType();
        final String jsonString = gson.toJson(sourceObject, sourceObjectType);
View Full Code Here

TOP

Related Classes of org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer

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.