org.springframework.http.converter.protobuf

Class ProtobufJsonFormatHttpMessageConverter

  • All Implemented Interfaces:
    HttpMessageConverter<com.google.protobuf.Message>


    public class ProtobufJsonFormatHttpMessageConverter
    extends ProtobufHttpMessageConverter
    Subclass of ProtobufHttpMessageConverter which enforces the use of Protobuf 3 and its official library "com.google.protobuf:protobuf-java-util" for JSON processing.

    Most importantly, this class allows for custom JSON parser and printer configurations through the JsonFormat utility. If no special parser or printer configuration is given, default variants will be used instead.

    Requires Protobuf 3.x and "com.google.protobuf:protobuf-java-util" 3.x, with 3.3 or higher recommended.

    Since:
    5.0
    Author:
    Juergen Hoeller, Sebastien Deleuze
    See Also:
    JsonFormat.parser(), JsonFormat.printer(), ProtobufJsonFormatHttpMessageConverter(JsonFormat.Parser, JsonFormat.Printer)
    • Constructor Detail

      • ProtobufJsonFormatHttpMessageConverter

        public ProtobufJsonFormatHttpMessageConverter()
        Construct a new ProtobufJsonFormatHttpMessageConverter with default JsonFormat.Parser and JsonFormat.Printer configuration.
      • ProtobufJsonFormatHttpMessageConverter

        public ProtobufJsonFormatHttpMessageConverter(@Nullable
                                                      com.google.protobuf.util.JsonFormat.Parser parser,
                                                      @Nullable
                                                      com.google.protobuf.util.JsonFormat.Printer printer)
        Construct a new ProtobufJsonFormatHttpMessageConverter with the given JsonFormat.Parser and JsonFormat.Printer configuration.
        Parameters:
        parser - the JSON parser configuration
        printer - the JSON printer configuration
      • ProtobufJsonFormatHttpMessageConverter

        public ProtobufJsonFormatHttpMessageConverter(@Nullable
                                                      com.google.protobuf.util.JsonFormat.Parser parser,
                                                      @Nullable
                                                      com.google.protobuf.util.JsonFormat.Printer printer,
                                                      @Nullable
                                                      com.google.protobuf.ExtensionRegistry extensionRegistry)
        Construct a new ProtobufJsonFormatHttpMessageConverter with the given JsonFormat.Parser and JsonFormat.Printer configuration, also accepting a registry that specifies protocol message extensions.
        Parameters:
        parser - the JSON parser configuration
        printer - the JSON printer configuration
        extensionRegistry - the registry to populate
        Since:
        5.1
      • ProtobufJsonFormatHttpMessageConverter

        @Deprecated
        public ProtobufJsonFormatHttpMessageConverter(@Nullable
                                                                  com.google.protobuf.util.JsonFormat.Parser parser,
                                                                  @Nullable
                                                                  com.google.protobuf.util.JsonFormat.Printer printer,
                                                                  @Nullable
                                                                  ExtensionRegistryInitializer registryInitializer)
        Construct a new ProtobufJsonFormatHttpMessageConverter with the given JsonFormat.Parser and JsonFormat.Printer configuration, also accepting an initializer that allows the registration of message extensions.
        Parameters:
        parser - the JSON parser configuration
        printer - the JSON printer configuration
        registryInitializer - an initializer for message extensions