Skip to Content
1
Former Member
Oct 10, 2017 at 06:09 PM

Remove Indentation in JSON Response of all OCC services

140 Views

Need to remove the extra spaces and whitelines from the response of all OCC services for Hybris 6.2 and above. Found the below code snippets for achieving that using Spring / Jackson. How do we achieve a similar result to remove / minify / optimize the response of all OCC services from hybris?

 @Bean
     public Jackson2ObjectMapperBuilder objectMapperBuilder() {
         Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
         builder.indentOutput(false);
         return builder;
     }

Or

 public class WhiteSpaceRemovalDeserializer extends JsonDeserializer<String> {
      @Override
      public String deserialize(JsonParser jp, DeserializationContext ctxt) {
          // This is where you can deserialize your value the way you want.
          // Don't know if the following expression is correct, this is just an idea.
          return jp.getCurrentToken().asText().trim();
      }
  }