本文整理汇总了Java中com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig类的典型用法代码示例。如果您正苦于以下问题:Java JsonEndpointConfig类的具体用法?Java JsonEndpointConfig怎么用?Java JsonEndpointConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonEndpointConfig类属于com.fasterxml.jackson.jaxrs.json包,在下文中一共展示了JsonEndpointConfig类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJSONGeneratorConfigured
import com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig; //导入依赖的package包/类
@Test
public void testJSONGeneratorConfigured() throws IOException {
JSONPrettyPrintFilter filter = new JSONPrettyPrintFilter();
ContainerRequest request = ContainerRequestBuilder.from("http://localhost/foo/bar?pretty", "GET").accept("random/media").build();
ContainerResponse response = new ContainerResponse(request, Response.ok().build());
filter.filter(request, response);
ObjectWriterModifier modifier = ObjectWriterInjector.get();
assertNotNull(modifier);
JsonGenerator g = mock(JsonGenerator.class);
modifier.modify(mock(JsonEndpointConfig.class), new MultivaluedHashMap<String, Object>(), new Object(), mock(ObjectWriter.class), g);
verify(g).useDefaultPrettyPrinter();
}
示例2: writeTo
import com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig; //导入依赖的package包/类
@Override
public void writeTo(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream os) throws IOException {
PropertyFiltering annotation = findPropertyFiltering(annotations);
Collection<String> properties = new ArrayList<>();
if (annotation != null) {
properties.addAll(getProperties(annotation.using()));
properties.addAll(Arrays.asList(annotation.always()));
}
PropertyFilter propertyFilter = createPropertyFilter(properties, o, type, genericType, annotations, httpHeaders);
if (!propertyFilter.hasFilters()) {
write(o, type, genericType, annotations, mediaType, httpHeaders, os);
return;
}
Timer timer = getTimer();
Timer.Context context = timer.time();
try {
ObjectMapper mapper = getJsonProvider().locateMapper(type, mediaType);
ObjectWriter writer = JsonEndpointConfig.forWriting(mapper.writer(), annotations, null).getWriter();
JsonNode tree = valueToTree(mapper, writer, o);
propertyFilter.filter(tree);
write(tree, tree.getClass(), tree.getClass(), annotations, mediaType, httpHeaders, os);
} finally {
context.stop();
}
}
开发者ID:HubSpot,项目名称:jackson-jaxrs-propertyfiltering,代码行数:31,代码来源:PropertyFilteringMessageBodyWriter.java
示例3: _configForWriting
import com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected JsonEndpointConfig _configForWriting(final ObjectMapper mapper, final Annotation[] annotations,
final Class<?> defaultView) {
return super._configForWriting(
JacksonUtils.configFilterIntrospector(mapper)
, annotations, defaultView);
}