当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.toArray方法代码示例

本文整理汇总了Java中org.json.simple.JSONArray.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.toArray方法的具体用法?Java JSONArray.toArray怎么用?Java JSONArray.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.simple.JSONArray的用法示例。


在下文中一共展示了JSONArray.toArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Logs

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public Logs(JSONArray jLogs) {

        for (Object jLog1 : jLogs) {

            JSONObject jLog = (JSONObject) jLog1;
            byte[] address = Hex.decode((String) jLog.get("address"));
            byte[] data = Hex.decode(((String) jLog.get("data")).substring(2));

            List<DataWord> topics = new ArrayList<>();

            JSONArray jTopics = (JSONArray) jLog.get("topics");
            for (Object t : jTopics.toArray()) {
                byte[] topic = Hex.decode(((String) t));
                topics.add(new DataWord(topic));
            }

            LogInfo li = new LogInfo(address, topics, data);
            logs.add(li);
        }
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:21,代码来源:Logs.java

示例2: init

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private void init(JSONArray jLogs) {
    logs = new ArrayList<>();
    for (Object jLog1 : jLogs) {

        JSONObject jLog = (JSONObject) jLog1;
        byte[] address = Hex.decode((String) jLog.get("address"));
        byte[] data = Hex.decode(((String) jLog.get("data")).substring(2));

        List<DataWord> topics = new ArrayList<>();

        JSONArray jTopics = (JSONArray) jLog.get("topics");
        for (Object t : jTopics.toArray()) {
            byte[] topic = Hex.decode(((String) t));
            topics.add(new DataWord(topic));
        }

        LogInfo li = new LogInfo(address, topics, data);
        logs.add(li);
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:21,代码来源:Logs.java

示例3: skipNullResults

import org.json.simple.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private JSONArray skipNullResults(JSONArray source, String propertyName) {
    JSONArray result = new JSONArray();
    for (Object item : source.toArray()) {
        if (((JSONObject) item).get(propertyName) == null) {
            continue;
        }
        result.add(item);
    }
    return result;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:12,代码来源:UserDataListDeclaredDoubleTest.java

示例4: compareJSONArray

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private static Result compareJSONArray(Result result, Object key, JSONArray source, JSONArray toBeCompared) {
    if (source == toBeCompared) {
        // nullチェック
        return result;
    }
    if (null == toBeCompared) {
        result.put(key,
                toBeCompared,
                String.format("Size of JSONArray [%s] is different. expected[%d], target[null]", key,
                        source.size()));
    }
    Object[] expectedArray = source.toArray();
    Object[] targetArray = toBeCompared.toArray();
    Arrays.sort(expectedArray);
    Arrays.sort(targetArray);
    if (expectedArray.length != targetArray.length) {
        result.put(key,
                toBeCompared,
                String.format("Size of JSONArray [%s] is different. expected[%d], target[%d]", key,
                        source.size(),
                        toBeCompared.size()));
        return result;
    }
    for (int i = 0; i < expectedArray.length; i++) {
        Object expected2 = expectedArray[i];
        Object target2 = targetArray[i];
        if (expected2 instanceof JSONObject && target2 instanceof JSONObject) {
            compareJSON(result, key, (JSONObject) expected2, (JSONObject) target2);
        } else if (!expected2.equals(target2)) {
            result.put(key,
                    toBeCompared,
                    String.format("Value of target of key[%s] does "
                            + "not have the same value as source JSON.  orignal: [%s], target[%s]",
                            key, source, toBeCompared));
        }
    }
    return result;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:39,代码来源:CompareJSON.java


注:本文中的org.json.simple.JSONArray.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。