spring-framework / org.springframework.http.converter.json / GsonBuilderUtils

GsonBuilderUtils

abstract class GsonBuilderUtils

A simple utility class for obtaining a Google Gson 2.x GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.

Author
Juergen Hoeller

Author
Roy Clarkson

Since
4.1

See Also
GsonFactoryBean#setBase64EncodeByteArraysorg.springframework.util.Base64Utils

Constructors

<init>

GsonBuilderUtils()

A simple utility class for obtaining a Google Gson 2.x GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.

Functions

gsonBuilderWithBase64EncodedByteArrays

open static fun gsonBuilderWithBase64EncodedByteArrays(): GsonBuilder

Obtain a GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.

A custom com.google.gson.TypeAdapter will be registered via GsonBuilder#registerTypeHierarchyAdapter(Class, Object) which serializes a byte[] property to and from a Base64-encoded String instead of a JSON array.