com.alibaba.fastjson.JSONArray.toJavaList()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(2602)

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

JSONArray.toJavaList介绍

暂无

代码示例

代码示例来源:origin: hs-web/hsweb-framework

@Override
public AuthenticationBuilder permission(String permissionJson) {
  JSONArray jsonArray = JSON.parseArray(permissionJson);
  List<Permission> permissions = new ArrayList<>();
  for (int i = 0; i < jsonArray.size(); i++) {
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    SimplePermission permission = new SimplePermission();
    permission.setId(jsonObject.getString("id"));
    permission.setName(jsonObject.getString("name"));
    JSONArray actions = jsonObject.getJSONArray("actions");
    if (actions != null) {
      permission.setActions(new HashSet<>(actions.toJavaList(String.class)));
    }
    JSONArray dataAccess = jsonObject.getJSONArray("dataAccesses");
    if (null != dataAccess) {
      permission.setDataAccesses(dataAccess.stream().map(JSONObject.class::cast)
          .map(dataJson -> dataBuilderFactory.create().fromJson(dataJson.toJSONString()).build())
          .filter(Objects::nonNull)
          .collect(Collectors.toSet()));
    }
    permissions.add(permission);
  }
  authentication.setPermissions(permissions);
  return this;
}

代码示例来源:origin: hs-web/hsweb-framework

return ((JSONArray) data).stream().map(autzParser).collect(Collectors.toList());
return ((JSONArray) data).toJavaList(type);

代码示例来源:origin: apache/rocketmq

public void load() {
  Map<String, PlainAccessResource> plainAccessResourceMap = new HashMap<>();
  List<RemoteAddressStrategy> globalWhiteRemoteAddressStrategy = new ArrayList<>();
  JSONObject plainAclConfData = AclUtils.getYamlDataObject(fileHome + File.separator + fileName,
    JSONObject.class);
  if (plainAclConfData == null || plainAclConfData.isEmpty()) {
    throw new AclException(String.format("%s file  is not data", fileHome + File.separator + fileName));
  }
  log.info("Broker plain acl conf data is : ", plainAclConfData.toString());
  JSONArray globalWhiteRemoteAddressesList = plainAclConfData.getJSONArray("globalWhiteRemoteAddresses");
  if (globalWhiteRemoteAddressesList != null && !globalWhiteRemoteAddressesList.isEmpty()) {
    for (int i = 0; i < globalWhiteRemoteAddressesList.size(); i++) {
      globalWhiteRemoteAddressStrategy.add(remoteAddressStrategyFactory.
          getRemoteAddressStrategy(globalWhiteRemoteAddressesList.getString(i)));
    }
  }
  JSONArray accounts = plainAclConfData.getJSONArray("accounts");
  if (accounts != null && !accounts.isEmpty()) {
    List<PlainAccessConfig> plainAccessConfigList = accounts.toJavaList(PlainAccessConfig.class);
    for (PlainAccessConfig plainAccessConfig : plainAccessConfigList) {
      PlainAccessResource plainAccessResource = buildPlainAccessResource(plainAccessConfig);
      plainAccessResourceMap.put(plainAccessResource.getAccessKey(),plainAccessResource);
    }
  }
  this.globalWhiteRemoteAddressStrategy = globalWhiteRemoteAddressStrategy;
  this.plainAccessResourceMap = plainAccessResourceMap;
}

代码示例来源:origin: hs-web/hsweb-framework

@Override
default PagerResult<E> selectPager(Entity param) {
  JSONObject result = createRequest("/", param).get().as(JSONObject.class);
  return PagerResult.of(result.getInteger("total"), result.getJSONArray("data").toJavaList(getEntityType()));
}

代码示例来源:origin: com.centit.framework/framework-adapter

public <T> List<T> getDataAsArray(String sKey, Class<T> clazz) {
  Object data = getData(sKey);
  if(data==null/* || !(data instanceof Map)*/)
    return null;
  if(data instanceof JSONArray) {
    return ((JSONArray)data).toJavaList(clazz);
  }
  return null;
}

代码示例来源:origin: com.centit.framework/framework-adapter

public <T> List<T> getDataAsArray(Class<T> clazz) {
  JSONArray jsonArray = resJSON.getJSONArray(ResponseData.RES_DATA_FILED);
  if(jsonArray==null)
    return null;
  return jsonArray.toJavaList(clazz);
}

代码示例来源:origin: aliyun/aliyun-odps-java-sdk

private Column parseColumn(JSONObject node) {
 String name = node.getString("name");
 String typeString = node.getString("type").toUpperCase();
 TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(typeString);
 String comment = node.getString("comment");
 String label = null;
 if (node.containsKey("label") && (!node.getString("label").isEmpty())) {
  label = node.getString("label");
 }
 List<String> extendedLabels = null;
 if (node.containsKey("extendedLabels") && (!node.getJSONArray("extendedLabels").isEmpty())) {
  extendedLabels = node.getJSONArray("extendedLabels").toJavaList(String.class);
 }
 return new Column(name, typeInfo, comment, label, extendedLabels);
}

代码示例来源:origin: org.hswebframework.web/hsweb-authorization-oauth2-client

return ((JSONArray) data).stream().map(autzParser).collect(Collectors.toList());
return ((JSONArray) data).toJavaList(type);

代码示例来源:origin: com.github.xiaolyuh/layering-cache-core

return (T) ((JSONArray) wrapper.getContent()).toJavaList(clazz);

代码示例来源:origin: xiaolyuh/layering-cache

return (T) ((JSONArray) wrapper.getContent()).toJavaList(clazz);

代码示例来源:origin: org.apache.rocketmq/rocketmq-acl

public void load() {
  Map<String, PlainAccessResource> plainAccessResourceMap = new HashMap<>();
  List<RemoteAddressStrategy> globalWhiteRemoteAddressStrategy = new ArrayList<>();
  JSONObject plainAclConfData = AclUtils.getYamlDataObject(fileHome + File.separator + fileName,
    JSONObject.class);
  if (plainAclConfData == null || plainAclConfData.isEmpty()) {
    throw new AclException(String.format("%s file  is not data", fileHome + File.separator + fileName));
  }
  log.info("Broker plain acl conf data is : ", plainAclConfData.toString());
  JSONArray globalWhiteRemoteAddressesList = plainAclConfData.getJSONArray("globalWhiteRemoteAddresses");
  if (globalWhiteRemoteAddressesList != null && !globalWhiteRemoteAddressesList.isEmpty()) {
    for (int i = 0; i < globalWhiteRemoteAddressesList.size(); i++) {
      globalWhiteRemoteAddressStrategy.add(remoteAddressStrategyFactory.
          getRemoteAddressStrategy(globalWhiteRemoteAddressesList.getString(i)));
    }
  }
  JSONArray accounts = plainAclConfData.getJSONArray("accounts");
  if (accounts != null && !accounts.isEmpty()) {
    List<PlainAccessConfig> plainAccessConfigList = accounts.toJavaList(PlainAccessConfig.class);
    for (PlainAccessConfig plainAccessConfig : plainAccessConfigList) {
      PlainAccessResource plainAccessResource = buildPlainAccessResource(plainAccessConfig);
      plainAccessResourceMap.put(plainAccessResource.getAccessKey(),plainAccessResource);
    }
  }
  this.globalWhiteRemoteAddressStrategy = globalWhiteRemoteAddressStrategy;
  this.plainAccessResourceMap = plainAccessResourceMap;
}

代码示例来源:origin: com.scireum/sirius-db

/**
 * Creates a new instance of the given entity type for the given data.
 *
 * @param ed  the descriptor of the entity type
 * @param obj the JSON data to transform
 * @return a new entity based on the given data
 */
protected static ElasticEntity make(EntityDescriptor ed, JSONObject obj) {
  try {
    JSONObject source = obj.getJSONObject(RESPONSE_SOURCE);
    JSONArray matchedQueries = obj.getJSONArray(MATCHED_QUERIES);
    ElasticEntity result = (ElasticEntity) ed.make(Elastic.class, null, key -> Value.of(source.get(key)));
    result.setId(obj.getString(ID_FIELD));
    if (matchedQueries != null) {
      result.setMatchedQueries(new HashSet<>(matchedQueries.toJavaList(String.class)));
    }
    if (ed.isVersioned()) {
      result.setVersion(obj.getInteger(RESPONSE_VERSION));
    }
    return result;
  } catch (Exception e) {
    throw Exceptions.handle(Elastic.LOG, e);
  }
}

代码示例来源:origin: aliyun/aliyun-odps-java-sdk

JSONArray tableExtendedLabels = tree.getJSONArray("extendedLabel");
if (!tableExtendedLabels.isEmpty()) {
  model.tableExtendedLabels = tableExtendedLabels.toJavaList(String.class);

相关文章

微信公众号

最新文章

更多