当前位置: 首页>>代码示例>>Java>>正文


Java JsonEndpointConfig类代码示例

本文整理汇总了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();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:TestJSONPrettyPrintFilter.java

示例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);
}
 
开发者ID:icode,项目名称:ameba,代码行数:10,代码来源:FilteringJacksonJsonProvider.java


注:本文中的com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。