leap.lang.yaml.YAML.decode()方法的使用及代码示例

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

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

YAML.decode介绍

[英]Decodes the yaml content to raw value.

The raw value may be null, map, list or simpl value.
[中]将yaml内容解码为原始值。
原始值可以是null、map、list或siml值。

代码示例

代码示例来源:origin: org.leapframework/leap-lang

/**
 * Parse the yaml content to {@link YamlValue}.
 */
public static YamlValue parse(Reader reader) throws YamlException {
  return YamlValue.of(decode(reader));
}

代码示例来源:origin: org.leapframework/leap-lang

/**
 * Parse the yaml content to {@link YamlValue}.
 */
public static YamlValue parse(String string) throws YamlException {
  return YamlValue.of(decode(string));
}

代码示例来源:origin: org.leapframework/jmms-plugins-swagger-doc

public SwaggerDoc(String dir) {
  this.dir = leap.lang.path.Paths.suffixWithSlash(dir);
  Map map = null;
  File swaggerFile = Paths.get(dir).resolve("./swagger.json").toFile();
  if(swaggerFile.exists()) {
    map = JSON.decodeMap(IO.readString(swaggerFile, Charsets.UTF_8));
  }else {
    swaggerFile = Paths.get(dir).resolve("./swagger.yaml").toFile();
    if(swaggerFile.exists()) {
      map = YAML.decode(Resources.createFileResource(swaggerFile).getContent());
    }
  }
  if(null != map) {
    this.swagger = JsonObject.of(map);
  }
}

代码示例来源:origin: org.leapframework/leap-webapi

@Override
public ApiMetadataBuilder read(Reader reader) throws IOException {
  String content = IO.readString(reader).trim();
  Map<String,Object> swagger;
  if(content.startsWith("{")) {
    swagger = JSON.decode(content);
  }else{
    swagger = YAML.decode(content);
  }
  ApiMetadataBuilder m = new ApiMetadataBuilder();
  readSwagger(swagger, m);
  return m;
}

代码示例来源:origin: org.leapframework/leap-core

protected void readMessages(MessageContext context, Resource resource) {
  try {
    String localeName = Locales.extractFromFilename(resource.getFilename());
    Locale locale     = Strings.isEmpty(localeName) ? null : Locales.forName(localeName);
    Map<String, String> props;
    try (Reader reader = resource.getInputStreamReader(charset)) {
      Map map = YAML.decode(reader);
      if (null == map || map.isEmpty()) {
        return;
      }
      props = Maps.toProperties(map);
    }
    for (String key : props.keySet()) {
      readMessage(context, resource, locale, props, (String) key);
    }
  } catch (Exception e) {
    throw new AppConfigException("Error reading messages from properties resource [" +
        resource.getURLString() + "], " + e.getMessage(), e);
  }
}

相关文章

微信公众号

最新文章

更多

YAML类方法