com.fasterxml.jackson.dataformat.yaml.YAMLMapper.setSerializationInclusion()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(274)

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

YAMLMapper.setSerializationInclusion介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

/**
 * Convert this RAML object to Yaml.
 *
 * @return Yaml string.
 * @throws IOException If something goes wrong.
 */
public String toYaml() throws IOException {
 YAMLMapper mapper = new YAMLMapper();
 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
 mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false);
 mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true);
 return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this);
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

public static <T> String toYamlString(T instance) {
  ObjectMapper mapper = new YAMLMapper()
      .disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID)
      .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
  try {
    return mapper.writeValueAsString(instance);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.github.duanxinyuan/library-json-jackson

private static void configPropertyInclusion() {
  mapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION);
  yamlMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION);
  propsMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION);
  csvMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION);
  xmlMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION);
}

代码示例来源:origin: org.jooby/jooby-apitool

/**
 * Convert this RAML object to Yaml.
 *
 * @return Yaml string.
 * @throws IOException If something goes wrong.
 */
public String toYaml() throws IOException {
 YAMLMapper mapper = new YAMLMapper();
 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
 mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false);
 mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true);
 return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this);
}

相关文章