Java Code Examples for com.google.gson.GsonBuilder#addSerializationExclusionStrategy()
The following examples show how to use
com.google.gson.GsonBuilder#addSerializationExclusionStrategy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExclusionStrategyFunctionalTest.java From gson with Apache License 2.0 | 5 votes |
private static Gson createGson(ExclusionStrategy exclusionStrategy, boolean serialization) { GsonBuilder gsonBuilder = new GsonBuilder(); if (serialization) { gsonBuilder.addSerializationExclusionStrategy(exclusionStrategy); } else { gsonBuilder.addDeserializationExclusionStrategy(exclusionStrategy); } return gsonBuilder .serializeNulls() .create(); }
Example 2
Source File: GGraphGsonConfigurator.java From graphical-lsp with Eclipse Public License 2.0 | 4 votes |
public GsonBuilder configureGsonBuilder(GsonBuilder gsonBuilder) { gsonBuilder.registerTypeAdapterFactory(new GModelElementTypeAdapter.Factory(DEFAULT_TYPE_ATT, typeMap)); configureClassesOfPackages(gsonBuilder); gsonBuilder.addSerializationExclusionStrategy(new EObjectExclusionStrategy()); return gsonBuilder; }
Example 3
Source File: GsonUtils.java From JuniperBot with GNU General Public License v3.0 | 4 votes |
public static Gson create() { GsonBuilder builder = new GsonBuilder(); builder.addDeserializationExclusionStrategy(new SuperclassExclusionStrategy()); builder.addSerializationExclusionStrategy(new SuperclassExclusionStrategy()); return builder.create(); }