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

The following examples show how to use com.google.gson.GsonBuilder#enableComplexMapKeySerialization() . 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: Actions.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private static Gson getGsonParser() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.enableComplexMapKeySerialization();
    gsonBuilder.registerTypeAdapter(XmlNode.NodeName.class, new NodeNameDeserializer());
    gsonBuilder.registerTypeAdapter(ActionLocation.class, new ActionLocation.ActionLocationAdapter());
    return gsonBuilder.create();
}
 
Example 2
Source File: Actions.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private static Gson getGsonParser() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.enableComplexMapKeySerialization();
    gsonBuilder.registerTypeAdapter(XmlNode.NodeName.class, new NodeNameDeserializer());
    MessageJsonSerializer.registerTypeAdapters(gsonBuilder);
    return gsonBuilder.create();
}
 
Example 3
Source File: CredentialBodyHandler.java    From divide with Apache License 2.0 5 votes vote down vote up
private Gson getGson() {
    if (gson == null) {
        final GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.enableComplexMapKeySerialization();
        gsonBuilder.setPrettyPrinting();
        gson = gsonBuilder.create();
    }
    return gson;
}
 
Example 4
Source File: GsonMessageBodyHandler.java    From divide with Apache License 2.0 5 votes vote down vote up
private Gson getGson() {
        if (gson == null) {
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.enableComplexMapKeySerialization();
//            gsonBuilder.setPrettyPrinting();
            gson = gsonBuilder.create();
        }
        return gson;
    }
 
Example 5
Source File: Actions.java    From buck with Apache License 2.0 5 votes vote down vote up
@NonNull
public String persist() throws IOException  {
    //noinspection SpellCheckingInspection
    GsonBuilder gson = new GsonBuilder().setPrettyPrinting();
    gson.enableComplexMapKeySerialization();
    MessageJsonSerializer.registerTypeAdapters(gson);
    return gson.create().toJson(this);
}
 
Example 6
Source File: Actions.java    From buck with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SpellCheckingInspection")
@NonNull
private static Gson getGsonParser() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.enableComplexMapKeySerialization();
    gsonBuilder.registerTypeAdapter(XmlNode.NodeName.class, new NodeNameDeserializer());
    MessageJsonSerializer.registerTypeAdapters(gsonBuilder);
    return gsonBuilder.create();
}
 
Example 7
Source File: EventSerializerGson.java    From JEEventStore with MIT License 5 votes vote down vote up
/**
    * Create the underlying GsonBuilder.
    * Added here to test proper serialization in integration tests.
    */
   public static GsonBuilder createBuilder() {
       GsonBuilder builder = new GsonBuilder();
       builder.registerTypeAdapter(EventList.class, new EventListTypeConverter());
builder.serializeSpecialFloatingPointValues(); // required to serialize Double.POSITIVE_INFINITY and others
       builder.enableComplexMapKeySerialization(); // required to properly serialize maps
       builder.setDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); // granularity of 1 ms
       return builder;
   }
 
Example 8
Source File: Actions.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public String persist() throws IOException  {
    GsonBuilder gson = new GsonBuilder().setPrettyPrinting();
    gson.enableComplexMapKeySerialization();
    gson.registerTypeAdapter(ActionLocation.class, new ActionLocation.ActionLocationAdapter());
    return gson.create().toJson(this);
}
 
Example 9
Source File: Actions.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public String persist() throws IOException  {
    GsonBuilder gson = new GsonBuilder().setPrettyPrinting();
    gson.enableComplexMapKeySerialization();
    MessageJsonSerializer.registerTypeAdapters(gson);
    return gson.create().toJson(this);
}