I want to make sure that the JSON files generated by Jackson are never pretty print. I’m a junior working on a pre-existing project, so I need to work backwards to find out all the ways that JSON can be configured to output as pretty print. I can confirm there are 0 references to .defaultPrettyPrintingWriter() in the project, as well as 0 references to .setSerializationConfig, which I believe may also be used to enable pretty print.
So how else is this possible? Alternatively, is there a sure-fire way to ensure the JSON file is not pretty print?
Depending on what version of Spring you are using the
MappingJacksonHttpMessageConvertershould have a boolean property namedprettyPrintto configure the printer when serializing JSON.So this XML configuration should do the trick (if you are using a recent version of Spring 3)
You can see the related commit on github introducing the property. And the trunk version of the class too, that includes this property. Finally this is the Spring Jira issue SPR-7201 related to the previous commit.
Or you could try to update your version of Jackson to a more recent one that includes the
useDefaultPrettyPrinterandsetPrettyPrintermethods as mentioned by Alexander Ryzhov