gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 09:28:40 26 4
gpt4 key购买 nike

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

YAMLMapper.writeValueAsString介绍

暂无

代码示例

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

/**
 * 序列化为YAML
 */
public static <V> String toYaml(V v) {
  try {
    return yamlMapper.writeValueAsString(v);
  } catch (JsonProcessingException e) {
    log.error("jackson to yaml error, obj: {}", v, e);
    return null;
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper();
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper();
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper();
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper();
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public String toString() {
  YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
  try {
    return mapper.writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: io.konig/konig-schemagen

private void readTags(String fileName, StringBuffer template) throws FileNotFoundException, IOException {
  File resourceFile = new File(path, fileName);
  if(resourceFile.exists()){
    try (InputStream inputStream = new FileInputStream(resourceFile)) {
      String contents = IOUtils.toString(inputStream);
      YAMLMapper mapper = new YAMLMapper(new YAMLFactory());
      JsonNode node = mapper.readTree(contents);
      JsonNode resourcesNode = node.get("Tags");
      String jsonAsYaml = new YAMLMapper().writeValueAsString(resourcesNode);
      String[] resourceLines=jsonAsYaml.split("\n");
      for(String line:resourceLines){
        if(!line.contains("---")){
          template.append(""+line+"\n      ");
        }
      }
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

@RequestMapping(value = "/swaggerDetailed.yaml", method = RequestMethod.GET, produces = "application/yaml")
public String getProjectSwaggerYaml() {
  ObjectMapper jsonWriter = new ObjectMapper()
      .setSerializationInclusion(JsonInclude.Include.NON_NULL);
  YAMLMapper yamlMapper = new YAMLMapper()
      .disable(WRITE_DOC_START_MARKER);
  try {
    Swagger swagger = swaggerGenerator.generateSwagger();
    JsonNode jsonNode = jsonWriter.readTree(
        jsonWriter.writeValueAsBytes(swagger));
    return yamlMapper.writeValueAsString(jsonNode);
  } catch (IOException e) {
    throw new RestAPIException("An error occurred while generating Swagger documentation", e.getMessage(),
        HttpStatus.INTERNAL_SERVER_ERROR, e);
  }
}

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

/**
 * Changes the {@code subject} of the RoleBinding in the given YAML resource to be the
 * {@code strimzi-cluster-operator} {@code ServiceAccount} in the given namespace.
 * @param roleBindingFile
 * @param namespace
 * @return role
 */
public static String changeRoleBindingSubject(File roleBindingFile, String namespace) {
  YAMLMapper mapper = new YAMLMapper();
  try {
    JsonNode node = mapper.readTree(roleBindingFile);
    ArrayNode subjects = (ArrayNode) node.get("subjects");
    ObjectNode subject = (ObjectNode) subjects.get(0);
    subject.put("kind", "ServiceAccount")
        .put("name", "strimzi-cluster-operator")
        .put("namespace", namespace);
    return mapper.writeValueAsString(node);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

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

public static String changeDeploymentNamespaceUpgrade(File deploymentFile, String namespace) {
  YAMLMapper mapper = new YAMLMapper();
  try {
    JsonNode node = mapper.readTree(deploymentFile);
    // Change the docker org of the images in the 050-deployment.yaml
    ObjectNode containerNode = (ObjectNode) node.at("/spec/template/spec/containers").get(0);
    for (JsonNode envVar : containerNode.get("env")) {
      String varName = envVar.get("name").textValue();
      if (varName.matches("STRIMZI_NAMESPACE")) {
        // Replace all the default images with ones from the $DOCKER_ORG org and with the $DOCKER_TAG tag
        ((ObjectNode) envVar).remove("valueFrom");
        ((ObjectNode) envVar).put("value", namespace);
      }
    }
    return mapper.writeValueAsString(node);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: EnMasseProject/enmasse

public String toYaml(String version) throws IOException {
  JsonNode jsonNodeTree = new ObjectMapper().readTree(this.toJson(version).toString());
  return new YAMLMapper().writeValueAsString(jsonNodeTree);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com