With Jackson, the annotation @JsonProperty("a") on a field would serialize its name as a. With Gson, this is to be done as @SerializedName("a").
Annotating all serialized fields of a class and going with the default Jackson setting would result in a minified JSON response which is what we want to achieve.
This obviously obfuscates the response, so it would be great to make this optional. With non-Production profiles the minifying should be turned off, whilst the Production profile should use the minified version.
The application uses Spring Boot 2 (REST + Data) and Java 8, and currently serializing with Jackson but that can change. The build is done via Maven.
We can use either Spring or Maven profiles for this.
Speculations:
Drop the annotations and configure Jackson / Gson with profile based beans. Unsure whether possible.
Jackson Annotations are currently not used. I could throw in my own implementation from an external module, and switch between the dummy and real one based on profile, hoping mine won't be autoconfigured. Dirty and may not work.
Duplicate the response entities, but this is ugly and hard to maintain.
Anyhow, the question is how to make JSON minifying configuration-based, toggleable.