/** * Obtain a {@link GsonBuilder} which Base64-encodes {@code byte[]} * properties when reading and writing JSON. * <p>A custom {@link com.google.gson.TypeAdapter} will be registered via * {@link GsonBuilder#registerTypeHierarchyAdapter(Class, Object)} which * serializes a {@code byte[]} property to and from a Base64-encoded String * instead of a JSON array. */ public static GsonBuilder gsonBuilderWithBase64EncodedByteArrays() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeHierarchyAdapter(byte[].class, new Base64TypeAdapter()); return builder; }
/** * Obtain a {@link GsonBuilder} which Base64-encodes {@code byte[]} * properties when reading and writing JSON. * <p>A custom {@link com.google.gson.TypeAdapter} will be registered via * {@link GsonBuilder#registerTypeHierarchyAdapter(Class, Object)} which * serializes a {@code byte[]} property to and from a Base64-encoded String * instead of a JSON array. */ public static GsonBuilder gsonBuilderWithBase64EncodedByteArrays() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeHierarchyAdapter(byte[].class, new Base64TypeAdapter()); return builder; }
/** * Obtain a {@link GsonBuilder} which Base64-encodes {@code byte[]} * properties when reading and writing JSON. * <p>A custom {@link com.google.gson.TypeAdapter} will be registered via * {@link GsonBuilder#registerTypeHierarchyAdapter(Class, Object)} which * serializes a {@code byte[]} property to and from a Base64-encoded String * instead of a JSON array. */ public static GsonBuilder gsonBuilderWithBase64EncodedByteArrays() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeHierarchyAdapter(byte[].class, new Base64TypeAdapter()); return builder; }
/** * Obtain a {@link GsonBuilder} which Base64-encodes {@code byte[]} * properties when reading and writing JSON. * <p>A custom {@link com.google.gson.TypeAdapter} will be registered via * {@link GsonBuilder#registerTypeHierarchyAdapter(Class, Object)} which * serializes a {@code byte[]} property to and from a Base64-encoded String * instead of a JSON array. */ public static GsonBuilder gsonBuilderWithBase64EncodedByteArrays() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeHierarchyAdapter(byte[].class, new Base64TypeAdapter()); return builder; }