leap.lang.json.JSON.decodeMap()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(143)

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

JSON.decodeMap介绍

[英]Parse the json string and returns the the array.
[中]解析json字符串并返回数组的值。

代码示例

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

/**
 * Parse the response content as json and decodes to map.
 */
default Map<String,Object> decodeJsonMap() {
  return JSON.decodeMap(getContent());
}

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

/**
 * Parse the json string and converts the raw value to the target type
 * @since 0.5.0b
 */
public static <T> Map<String, T> decodeMap(String json, Class<? extends T> valueType){
  Map<String, Object> map = decodeMap(json);
  for(Map.Entry<String, Object> entry : map.entrySet()){
    entry.setValue(Converts.convert(entry.getValue(),valueType, null, convertContext));
  }
  return (Map<String, T>) map;
}

代码示例来源:origin: org.leapframework/jmms-engine

protected final <T extends MetaObj> T decodeJsonStr(String json, Class<T> type) {
  return decodeJsonMap(JSON.decodeMap(json), type);
}

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

protected void readInclude(Resource resource, Map<String, Object> root, String incPath)  {
  try {
    Resource incRes = resource.createRelative(incPath);
    if (!incRes.exists()) {
      throw new IllegalStateException("The included file '" + incPath + "' not found");
    }
    root.putAll(JSON.decodeMap(incRes.getContent()));
  }catch (IOException e){
    throw new UncheckedIOException("Err read include '" + incPath + "', " + e.getMessage(), e);
  }
}

代码示例来源: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-lang

private List<KV> flat(){
  List<KV> flat = new ArrayList<>();
  list.forEach(kv -> {
    String key = kv.key;
    Object value = kv.value;
    if(value == null || Beans.isSimpleProperty(value.getClass())){
      flat.add(new KV(key,value));
    }else {
      JsonObject json = JsonObject.of(JSON.decodeMap(JSON.encode(value)));
      addFlatList(key,json,flat);
    }
  });
  return flat;
}

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

return val;
} else if (rawType.isAssignableFrom(Map.class)) {
  Map<String, Object> val = JSON.decodeMap(jsonStr, (Class<?>) actualTypes[0]);
  return (T) val;
} else {

代码示例来源:origin: org.leapframework/jmms-engine

public void read(Map<String,MetaFormat> formats, Resource resource) {
  Map<String, Object> map = JSON.decodeMap(resource.getContent());
  map.forEach((k,v) -> {
    MetaFormat f = formats.get(k.toLowerCase());
    if(null != f) {
      throw new IllegalStateException("Found duplicated format at [" + f.getSource() + ", " + resource.getURLString() + "]");
    }
    f = Converts.convert(v, MetaFormat.class);
    if(Strings.isEmpty(f.getName())) {
      f.setName(k);
    }
    validator.validate(f);
    formats.put(k.toLowerCase(), f);
  });
}

代码示例来源:origin: org.leapframework/jmms-engine

private static void read(PlaceholderResolver pr, Map<String,String> all, String prefix, String profile, Resource resource, Predicate<String> filter) {
  Map<String, Object> map   = Utils.readAndGet(resource, (file) -> JSON.decodeMap(file.getContent()));
  Map<String, String> props = toProperties(map, prefix);

代码示例来源:origin: org.leapframework/jmms-engine

public void read(MetaApi api, Resource resource) {
  String content = resource.getContent();
  if (Strings.isEmpty(content)) {
    return;
  }
  Map<String, Object> map = JSON.decodeMap(content);
  map.forEach((k, o) -> {
    if (!(o instanceof Map)) {
      throw new IllegalStateException("Invalid filters '" + k + "'");
    }
    MetaQueryFilterSet qfs;
    Map m = (Map) o;
    if (m.containsKey("filters")) {
      qfs = Converts.convert(o, MetaQueryFilterSet.class);
    } else {
      qfs = Converts.convert(New.hashMap("filters", m), MetaQueryFilterSet.class);
    }
    if (Strings.isEmpty(qfs.getName())) {
      qfs.setName(k);
    }
    processFilterSet(qfs);
    api.addFilterSet(qfs);
  });
}

代码示例来源:origin: org.leapframework/jmms-engine

public void read(MetaApi api, Resource resource) {
  String content = resource.getContent();
  if(Strings.isEmpty(content)) {
    return;
  }
  Map<String, Object> map = JSON.decodeMap(resource.getContent());
  map.forEach((k,v) -> {
    MetaPermission p = api.getPermissions().get(k);
    if(null != p) {
      throw new IllegalStateException("Found duplicated permission at [" + p.getSource() + ", " + resource.getURLString() + "]");
    }
    p = Converts.convert(v, MetaPermission.class);
    if(Strings.isEmpty(p.getName())) {
      p.setName(k);
    }
    validator.validate(p);
    withSource(p, resource);
    api.addPermission(p);
  });
}

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

private Map data(JsonObject swagger) {
  Map data = JSON.decodeMap(swagger.toString());
  swagger  = JsonObject.of(data);

代码示例来源:origin: org.leapframework/jmms-engine

String main = (String) JSON.decodeMap(pkg.getContent()).get("main");
if(!Strings.isEmpty(main)) {
  return createRelative(dir, main, possiblePaths);

相关文章