Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProtobufHttpMessageConverter: Make JSON format configurable [SPR-15550] #20109

Closed
spring-projects-issues opened this issue May 15, 2017 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 15, 2017

Andreas Ahlenstorf opened SPR-15550 and commented

I would like to be able to configure/customize the JsonFormat.Printer used by ProtobufJavaUtilSupport in the ProtobufHttpMessageConverter in order to influence the format of the generated JSON. This is currently not possible and requires the reimplementation of the entire MessageConverter.

One possible solution would be to offer another constructor of ProtobufHttpMessageConverter that takes a ProtobufFormatSupport instance as single argument. ProtobufJavaUtilSupport and ProtobufJavaFormatSupport would have to be made public and ProtobufJavaUtilSupport would get an additional constructor with JsonFormat.Parser and JsonFormat.Printer as arguments. The default behaviour could remain the same.


Affects: 5.0 RC1

Issue Links:

Referenced from: commits ce5e2b9

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 22, 2017

Juergen Hoeller commented

I've introduced a dedicated ProtobufJsonFormatHttpMessageConverter as a subclass of ProtobufHttpMessageConverter, exposing an overloaded constructor with JsonFormat.Parser and JsonFormat.Printer arguments. This requires Protobuf 3.x and protobuf-java-util 3.x since it exposes the specific JsonFormat type from the latter.

The common ProtobufHttpMessageConverter keeps doing the best possible default job on Protobuf 2.6 or 3.x, using protobuf-java-format or protobuf-java-util if present on the classpath but also working without any format library if the standard Protobuf format is sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants