當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。