Reputation: 2416
Jackson offers the methods:
ObjectWriter ObjectMapper.writer(FilterProvider)
ObjectWriter ObjectMapper.writer(PrettyPrinter)
ObjectWriter ObjectMapper.writerWithDefaultPrettyPrinter()
But I want to use both pretty printing and a custom FilterProvider in my writer. How do I get a writer that uses both?
Upvotes: 3
Views: 1393
Reputation: 25613
You can take still configure this on the ObjectWriter
instance returned by any of the ObjectMapper.write()
method:
ObjectWriter objectWriter = ObjectMapper.writer(yourFilterProvider).withPrettyPrinter(yourPrettyPrinter);
// or
ObjectWriter objectWriter = ObjectMapper.writer(yourPrettyPrinter).withFilters(yourPrettyPrinter);
See the ObjectWriter class for more information
Upvotes: 5