com.fasterxml.jackson.databind.ObjectMapper.getVisibilityChecker()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中com.fasterxml.jackson.databind.ObjectMapper.getVisibilityChecker()方法的一些代码示例,展示了ObjectMapper.getVisibilityChecker()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper.getVisibilityChecker()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.ObjectMapper
类名称:ObjectMapper
方法名:getVisibilityChecker

ObjectMapper.getVisibilityChecker介绍

[英]Method for accessing currently configured visibility checker; object used for determining whether given property element (method, field, constructor) can be auto-detected or not.
[中]访问当前配置的可见性检查器的方法;对象,用于确定是否可以自动检测给定的属性元素(方法、字段、构造函数)。

代码示例

代码示例来源:origin: stackoverflow.com

import java.io.File;

import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.map.ObjectMapper;

public class JacksonFoo
{
 public static void main(String[] args) throws Exception
 {
  ObjectMapper mapper = new ObjectMapper();  
  mapper.setVisibilityChecker(  
   mapper.getVisibilityChecker()  
    .withFieldVisibility(Visibility.ANY));
  Thing thing = mapper.readValue(new File("input.json"), Thing.class);
  System.out.println(mapper.writeValueAsString(thing));
 }
}

代码示例来源:origin: com.bugsnag/bugsnag

/**
 * Constructor.
 */
// Use deprecated method to ensure we don't break with older versions of jackson
@SuppressWarnings("deprecation")
public Serializer() {
  mapper
    .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
    .setVisibilityChecker(
      mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
}

代码示例来源:origin: bugsnag/bugsnag-java

/**
 * Constructor.
 */
// Use deprecated method to ensure we don't break with older versions of jackson
@SuppressWarnings("deprecation")
public Serializer() {
  mapper
    .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
    .setVisibilityChecker(
      mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
}

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));

代码示例来源:origin: io.fabric8/fabric8-cxf

public void init() {
  LOG.log(Level.INFO, "Creating JsonSchemaLookup instance");
  try {
    if (mapper == null) {
      mapper = new ObjectMapper();
      mapper.setVisibility(new IgnorePropertiesBackedByTransientFields(mapper.getVisibilityChecker()));
      JaxbAnnotationModule module1 = new JaxbAnnotationModule();
      mapper.registerModule(module1);
      BeanValidationAnnotationModule module2 = new BeanValidationAnnotationModule();
      mapper.registerModule(module2);
    }
    // now lets expose the mbean...
    singleton = this;
  } catch (Exception e) {
    LOG.log(Level.WARNING, "Exception during initialization: ", e);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

public void init() {
  LOG.log(Level.INFO, "Creating JsonSchemaLookup instance");
  try {
    if (mapper == null) {
      mapper = new ObjectMapper();
      mapper.setVisibilityChecker(new IgnorePropertiesBackedByTransientFields(mapper.getVisibilityChecker()));
      JaxbAnnotationModule module1 = new JaxbAnnotationModule();
      mapper.registerModule(module1);
      BeanValidationAnnotationModule module2 = new BeanValidationAnnotationModule();
      mapper.registerModule(module2);
    }
    // now lets expose the mbean...
    singleton = this;
  } catch (Exception e) {
    LOG.log(Level.WARNING, "Exception during initialization: ", e);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: io.hawt/hawtio-json-schema-mbean

public void init() {
  LOG.debug("Creating hawtio SchemaLookup instance");
  try {
    if (mapper == null) {
      mapper = new ObjectMapper();
      mapper.setVisibilityChecker(new IgnorePropertiesBackedByTransientFields(mapper.getVisibilityChecker()));
      JaxbAnnotationModule module1 = new JaxbAnnotationModule();
      mapper.registerModule(module1);
      BeanValidationAnnotationModule module2 = new BeanValidationAnnotationModule();
      mapper.registerModule(module2);
    }
    // now lets expose the mbean...
    super.init();
    singleton = this;
  } catch (Exception e) {
    LOG.warn("Exception during initialization: ", e);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
System.out.println(mapper.writeValueAsString(new Placement()));

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
System.out.println(mapper.writeValueAsString(new Placement()));

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
System.out.println(mapper.writeValueAsString(new Placement()));

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
System.out.println(mapper.writeValueAsString(new Placement()));

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
mapper.getSerializationConfig().addMixInAnnotations(Placement.class, SkipFileDataMixIn.class);
System.out.println(mapper.writeValueAsString(new Placement()));

代码示例来源:origin: bugsnag/bugsnag-java

@SuppressWarnings("deprecation")
private JsonNode serialiseThreadStateToJson(List<ThreadState> threadStates) throws IOException {
  ObjectMapper mapper = new ObjectMapper();
  mapper
      .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
      .setVisibilityChecker(mapper.getVisibilityChecker()
          .with(JsonAutoDetect.Visibility.NONE));
  String json = mapper.writeValueAsString(threadStates);
  return mapper.readTree(json);
}

代码示例来源:origin: stackoverflow.com

mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));

相关文章

微信公众号

最新文章

更多

ObjectMapper类方法