I have a db that stores JSON strings. I want a controller that just returns these JSON strings. My problem is that the strings get escaped because I have configured a messageConverter:
So that this controller:Code:@Bean MappingJacksonHttpMessageConverter mappingJacksonHttpMessageConverter() { MappingJacksonHttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJacksonHttpMessageConverter(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); mappingJacksonHttpMessageConverter.setObjectMapper(objectMapper); mappingJacksonHttpMessageConverter.setPrettyPrint(true); return mappingJacksonHttpMessageConverter; }
leads to an output of "{\"a\":1, \"b\":\"foo\"}", which isn't what I want. I want the message converter there because not all of my methods are like this, many of them return objects and I like the message converters behavior.Code:@RequestMapping(value = "test", method = RequestMethod.GET) public @ResponseBody String getTest() { return "{\"a\":1, \"b\":\"foo\"}"; }
Is there some way to skip the message converter for certain methods? Is there an annotation / other way I can indicate that this is a raw json string I am returning? Any thoughts / suggestions for how to best tackle this would be appreciated. Thanks.


Reply With Quote
