@Override
    public JsonElement serialize(Dashboard dashboard, Type type, JsonSerializationContext context)
    {
        JsonElement element = gson.toJsonTree(dashboard, type);
        JsonObject obj = new JsonObject();
        obj.add("dashboard", element);
        return obj;
    }
@ Override public JsonElement serialize ( Dashboard dashboard , Type type , JsonSerializationContext context ) { JsonElement element = gson . toJsonTree ( dashboard , type ) ; JsonObject obj = new JsonObject ( ) ; obj . add ( "dashboard" , element ) ; return obj ; }
Gson invokes this call-back method during serialization when it encounters a field of the specified type.
@param dashboard The dashboard being serialized
@param type The type of the Object to deserialize to
@param context The JSON serialization context
@return The JSON data that was serialized