use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project webanno by webanno.
the class EntityTest method toJsonTest.
@Test
public void toJsonTest() throws IOException {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
String json = JSONUtil.toPrettyJsonString(jsonConverter, new Entity(new VID(1, 2), "type", new Offsets(1, 2), "label", "color", "somehoverspantext"));
assertEquals("[ \"1.2\", \"type\", [ [ 1, 2 ] ], \"label\", \"color\", \"somehoverspantext\" ]", json);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project webanno by webanno.
the class RelationTest method toJsonTest.
@Test
public void toJsonTest() throws IOException {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
String json = JSONUtil.toPrettyJsonString(jsonConverter, new Relation(new VID(1, 2), "type", asList(new Argument("arg1", 1), new Argument("arg2", 2)), "label", "color"));
assertEquals("[ \"1.2\", \"type\", [ [ \"arg1\", \"1\" ], [ \"arg2\", \"2\" ] ], \"label\", \"color\" ]", json);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project rpki-validator-3 by RIPE-NCC.
the class ApiConfig method extendMessageConverters.
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(Arrays.asList(MediaType.valueOf("text/json")));
converters.add(converter);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project rpki-validator-3 by RIPE-NCC.
the class ApiConfig method extendMessageConverters.
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
converter.setSupportedMediaTypes(Arrays.asList(MediaType.valueOf("text/json")));
converter.setPrettyPrint(true);
converters.add(converter);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project x-pipe by ctripcorp.
the class RestTemplateFactory method createCommonsHttpRestTemplate.
public static RestOperations createCommonsHttpRestTemplate(int maxConnPerRoute, int maxConnTotal, int connectTimeout, int soTimeout, int retryTimes, RetryPolicyFactory retryPolicyFactory) {
HttpClient httpClient = HttpClientBuilder.create().setMaxConnPerRoute(maxConnPerRoute).setMaxConnTotal(maxConnTotal).setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(soTimeout).build()).setDefaultRequestConfig(RequestConfig.custom().setConnectTimeout(connectTimeout).build()).build();
ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(factory);
// set jackson mapper
for (HttpMessageConverter<?> hmc : restTemplate.getMessageConverters()) {
if (hmc instanceof MappingJackson2HttpMessageConverter) {
ObjectMapper objectMapper = createObjectMapper();
MappingJackson2HttpMessageConverter mj2hmc = (MappingJackson2HttpMessageConverter) hmc;
mj2hmc.setObjectMapper(objectMapper);
}
}
return (RestOperations) Proxy.newProxyInstance(RestOperations.class.getClassLoader(), new Class[] { RestOperations.class }, new RetryableRestOperationsHandler(restTemplate, retryTimes, retryPolicyFactory));
}
Aggregations