Java Code Examples for com.google.gson.GsonBuilder#addDeserializationExclusionStrategy()

The following examples show how to use com.google.gson.GsonBuilder#addDeserializationExclusionStrategy() . 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 vote down vote up
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: GsonUtils.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
public static Gson create() {
    GsonBuilder builder = new GsonBuilder();
    builder.addDeserializationExclusionStrategy(new SuperclassExclusionStrategy());
    builder.addSerializationExclusionStrategy(new SuperclassExclusionStrategy());
    return builder.create();
}
 
Example 3
Source File: AttachmentDeserializer.java    From fb-botmill with MIT License 4 votes vote down vote up
/**
 * Instantiates a new AttachmentDeserializer.
 */
public AttachmentDeserializer() {
	GsonBuilder builder = new GsonBuilder();
	builder.addDeserializationExclusionStrategy(new SkipDeserializationAnnotationExclusionStrategy());
	delegateGson = builder.create();
}