Examples of serializeNulls()


Examples of com.google.gson.GsonBuilder.serializeNulls()

            this.home = discoverHome();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        GsonBuilder gsonBuilder = new GsonBuilder();
        gson = gsonBuilder.serializeNulls().create();
    }

    protected static ContextBrokerHomeImpl discoverHome() throws Exception {
        InitialContext ctx = null;
        try {
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

        .build());
  }

  public static <T> T getJsonFormString(String json, Class<T> type) {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.serializeNulls();
    Gson gson = gsonBuilder.create();
    return (T) gson.fromJson(json, type);
  }

  @Override
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

            }
            if (fieldNamingStrategy != null) {
                builder.setFieldNamingStrategy(fieldNamingStrategy);
            }
            if (serializeNulls != null && serializeNulls) {
                builder.serializeNulls();
            }
            if (prettyPrinting != null && prettyPrinting) {
                builder.setPrettyPrinting();
            }
            if (dateFormatPattern != null) {
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

  @Override
  public void afterPropertiesSet() {
    GsonBuilder builder = (this.base64EncodeByteArrays ?
        GsonBuilderUtils.gsonBuilderWithBase64EncodedByteArrays() : new GsonBuilder());
    if (this.serializeNulls) {
      builder.serializeNulls();
    }
    if (this.prettyPrinting) {
      builder.setPrettyPrinting();
    }
    if (this.disableHtmlEscaping) {
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

  public static JsonElement toJson(Object object, boolean serializeNullFields) {
    Preconditions.checkNotNull(object, "null object not allowed");
    GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(
        DateTime.class, new GsonDateTimeSerializer());
    if (serializeNullFields) {
      gsonBuilder.serializeNulls();
    }
    Gson gson = gsonBuilder.create();
    return gson.toJsonTree(object);
  }
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

        }
        if (fieldNamingStrategy != null) {
            builder.setFieldNamingStrategy(fieldNamingStrategy);
        }
        if (serializeNulls != null && serializeNulls) {
            builder.serializeNulls();
        }
        if (prettyPrinting != null && prettyPrinting) {
            builder.setPrettyPrinting();
        }
        if (dateFormatPattern != null) {
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

            }
            return new JsonPrimitive(json);
          }
        });
   
    return gsonBuilder.serializeNulls().create();
  }
 
  private SerializationUtils() {}
 
  /**
 
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

    }
  }
 
  public static Object toObject(String json) throws JsonException {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.serializeNulls();
    gsonBuilder.registerTypeAdapter(Object.class, new NaturalGsonDeserializer());
    Gson gson = gsonBuilder.create();
    return gson.fromJson(json, Object.class);
  }
 
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

    // Register custom type adapters.
    for (Entry<Type, Object> entry : customTypeAdapters.entrySet()) {
      builder.registerTypeAdapter(entry.getKey(), entry.getValue());
    }

    return builder.serializeNulls().create();
  }

  /**
   * A strategy definition that excludes all fields that are annotated with
   * {@link NonJsonSerializable}.
View Full Code Here

Examples of com.google.gson.GsonBuilder.serializeNulls()

    public CommandProcessingResultJsonSerializer() {
        final GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
        builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
        builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter());
        builder.serializeNulls();

        this.gson = builder.create();
    }

    public String serialize(final Object result) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.