org.springframework.http.converter.json

Class GsonBuilderUtils

  • java.lang.Object
    • org.springframework.http.converter.json.GsonBuilderUtils


  • public abstract class GsonBuilderUtils
    extends java.lang.Object
    A simple utility class for obtaining a Google Gson 2.x GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.
    Since:
    4.1
    Author:
    Juergen Hoeller, Roy Clarkson
    See Also:
    GsonFactoryBean.setBase64EncodeByteArrays(boolean), Base64Utils
    • Constructor Summary

      Constructors 
      Constructor and Description
      GsonBuilderUtils() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static com.google.gson.GsonBuilder gsonBuilderWithBase64EncodedByteArrays()
      Obtain a GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GsonBuilderUtils

        public GsonBuilderUtils()
    • Method Detail

      • gsonBuilderWithBase64EncodedByteArrays

        public static com.google.gson.GsonBuilder gsonBuilderWithBase64EncodedByteArrays()
        Obtain a GsonBuilder which Base64-encodes byte[] properties when reading and writing JSON.

        A custom 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.