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


Java JSONArray.addAll方法代码示例

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


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

示例1: mergeFiles

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * merge source file into target
 *
 * @param target
 * @param source
 */
public void mergeFiles(File target, File source) throws Throwable {
    String targetReport = FileUtils.readFileToString(target);
    String sourceReport = FileUtils.readFileToString(source);

    JSONParser jp = new JSONParser();

    try {
        JSONArray parsedTargetJSON = (JSONArray) jp.parse(targetReport);
        JSONArray parsedSourceJSON = (JSONArray) jp.parse(sourceReport);
        // Merge two JSON reports
        parsedTargetJSON.addAll(parsedSourceJSON);
        // this is a new writer that adds JSON indentation.
        Writer writer = new JSONWriter();
        // convert our parsedJSON to a pretty form
        parsedTargetJSON.writeJSONString(writer);
        // and save the pretty version to disk
        FileUtils.writeStringToFile(target, writer.toString());
    } catch (ParseException pe) {
        pe.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:usman-h,项目名称:Habanero,代码行数:30,代码来源:JSONReportMerger.java

示例2: loadDefaultTheme

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static void loadDefaultTheme(JSONObject obj) {
    try {
        appSett.putAll(System.getProperties());
        Object Theme = appSett.get(RDS.TestSet.THEME);
        if (Theme == null || Theme.toString().isEmpty()) {
            Theme = getFirstTheme();
        }
        obj.put(RDS.TestSet.THEME, Theme.toString());
        if (appSett.get(RDS.TestSet.THEMES) != null) {
            String[] themes = appSett.get(RDS.TestSet.THEMES).toString().split(",");
            JSONArray jsthemes = new JSONArray();
            jsthemes.addAll(Arrays.asList(themes));
            obj.put(RDS.TestSet.THEMES, jsthemes);
        }
    } catch (Exception ex) {
        Logger.getLogger(ReportUtils.class.getName()).log(Level.WARNING, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:19,代码来源:ReportUtils.java

示例3: putArray

import org.json.simple.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void putArray(String key, List<String> value) {
  // Frustratingly inefficient, but there you have it.
  final JSONArray jsonArray = new JSONArray();
  jsonArray.addAll(value);
  this.putRaw(key, jsonArray);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:8,代码来源:ExtendedJSONObject.java

示例4: copyVisits

import org.json.simple.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private JSONArray copyVisits() {
  if (this.visits == null) {
    return null;
  }
  JSONArray out = new JSONArray();
  out.addAll(this.visits);
  return out;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:10,代码来源:HistoryRecord.java

示例5: showVpnCommunities

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * This function collects all the vpn communities which exist on the management server
 *
 * @return the object collection
 */
private static JSONArray showVpnCommunities() {

    ApiResponse res;
    JSONArray objectsInUse = new JSONArray();
    List<String> commands = new ArrayList<>();
    commands.add("show-vpn-communities-star");
    commands.add("show-vpn-communities-meshed");

    for (String command : commands) {
        try {
            configuration.getLogger().debug("Run command: '" + command + "' with details level 'full'");
            res = client.apiQuery(loginResponse,command, "objects", "{\"details-level\" : \"full\"}");
        }
        catch (ApiClientException e) {
            configuration.getLogger().warning("Failed to execute command: " +command + ". Exception: " + e.getMessage());
            continue;
        }
        if(res == null || !res.isSuccess() ) {
            configuration.getLogger().warning("Failed to execute command: " +command + ". " + errorResponseToString(res));
            continue;
        }
        JSONArray allVpnCommunities = (JSONArray)res.getPayload().get("objects");

        objectsInUse.addAll(allVpnCommunities);
    }

        int numberObjectsInUse = objectsInUse.size();
        configuration.getLogger().debug("Found " +numberObjectsInUse + " vpn communities");

    return objectsInUse;
}
 
开发者ID:CheckPoint-APIs-Team,项目名称:ShowPolicyPackage,代码行数:37,代码来源:ShowPackageTool.java

示例6: JSONObject

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * UserDataの一覧でDouble配列型プロパティにnullを含むデータを取得できること.
 */
@SuppressWarnings("unchecked")
@Test
public final void UserDataの一覧でDouble配列型プロパティにnullを含むデータを取得できること() {
    String propName = "arrayDoubleTypeProperty";
    String userDataId = "userdata001";
    // リクエスト実行
    try {
        // Edm.Double配列のプロパティを作成
        PropertyUtils.create(AbstractCase.BEARER_MASTER_TOKEN, cellName, boxName, colName, entityTypeName,
                propName,
                EdmSimpleType.DOUBLE.getFullyQualifiedTypeName(),
                true, null, "List", false, null, HttpStatus.SC_CREATED);
        // リクエストボディを設定
        JSONObject body = new JSONObject();
        JSONArray arrayBody = new JSONArray();
        arrayBody.addAll(Arrays.asList(new Double[] {1.1, null, -1.2 }));
        body.put("__id", userDataId);
        body.put(propName, arrayBody);
        // ユーザデータ作成
        TResponse respons = createUserData(body, HttpStatus.SC_CREATED);

        Map<String, String> etagList = new HashMap<String, String>();
        etagList.put("userdata001", respons.getHeader(HttpHeaders.ETAG));

        // ユーザデータの一覧取得
        TResponse response = Http.request("box/odatacol/list.txt")
                .with("cell", cellName)
                .with("box", boxName)
                .with("collection", colName)
                .with("entityType", entityTypeName)
                .with("query", "")
                .with("accept", MediaType.APPLICATION_JSON)
                .with("token", PersoniumUnitConfig.getMasterToken())
                .returns()
                .statusCode(HttpStatus.SC_OK)
                .debug();

        Map<String, String> uri = new HashMap<String, String>();
        uri.put(userDataId, UrlUtils.userData(cellName, boxName, colName, entityTypeName
                + "('" + userDataId + "')"));

        // プロパティ
        Map<String, Map<String, Object>> additional = new HashMap<String, Map<String, Object>>();
        Map<String, Object> additionalprop = new HashMap<String, Object>();
        additional.put(userDataId, additionalprop);
        additionalprop.put("__id", userDataId);
        additionalprop.put(propName, arrayBody);

        String nameSpace = getNameSpace(entityTypeName);
        ODataCommon
                .checkResponseBodyList(response.bodyAsJson(), uri, nameSpace, additional, "__id", null, etagList);

    } finally {
        // ユーザデータ削除
        deleteUserData(userDataId);
        // プロパティ削除
        PropertyUtils.delete(AbstractCase.BEARER_MASTER_TOKEN, cellName, boxName, colName, entityTypeName,
                propName, -1);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:64,代码来源:UserDataListTest.java

示例7: getAutoModeJSONList

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public JSONArray getAutoModeJSONList() {
	JSONArray list = new JSONArray();
	list.addAll(getAutoModeList());
	return list;
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:6,代码来源:AutoModeSelector.java

示例8: tick

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * Called every tick
 */
public void tick() {

    JSONObject json = new JSONObject();
    json.put("t", "tick");

    LogManager.LOGGER.info("Notified " + userManager.getOnlineUsers().size() + " users");

    ArrayList<OnlineUser> onlineUsers = new ArrayList<>(userManager.getOnlineUsers()); //Avoid ConcurrentModificationException
    for (OnlineUser user : onlineUsers) {

        if (user.getWebSocket().isOpen()) {

            if (user.isGuest()) {

                json.remove("c");
                user.getWebSocket().send(json.toJSONString());

            } else {
                try {
                    ControllableUnit unit = user.getUser().getControlledUnit();

                    //Send keyboard updated buffer
                    ArrayList<Integer> kbBuffer = unit.getKeyboardBuffer();
                    JSONArray keys = new JSONArray();
                    keys.addAll(kbBuffer);
                    json.put("keys", keys);

                    //Send console buffer
                    if (unit.getConsoleMessagesBuffer().size() > 0) {

                        JSONArray buff = new JSONArray();

                        for (char[] message : unit.getConsoleMessagesBuffer()) {
                            buff.add(new String(message));
                        }

                        json.put("c", buff);
                    } else {
                        json.remove("c");
                    }

                    json.put("cm", unit.getConsoleMode());


                    //Send tick message
                    user.getWebSocket().send(json.toJSONString());
                } catch (NullPointerException e) {
                    //User is online but not completely initialised
                }

            }


        }
    }

}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:61,代码来源:SocketServer.java


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