本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例7: getAutoModeJSONList
import org.json.simple.JSONArray; //导入方法依赖的package包/类
public JSONArray getAutoModeJSONList() {
JSONArray list = new JSONArray();
list.addAll(getAutoModeList());
return list;
}
示例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
}
}
}
}
}