本文整理了Java中net.sf.json.JSONArray.add()
方法的一些代码示例,展示了JSONArray.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.add()
方法的具体详情如下:
包路径:net.sf.json.JSONArray
类名称:JSONArray
方法名:add
暂无
代码示例来源:origin: jenkinsci/jenkins
private JSONArray copyAndSanitizeArray(JSONArray jsonArray) {
JSONArray result = new JSONArray();
jsonArray.forEach(value ->
result.add(copyAndSanitize(value))
);
return result;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Like {@link #doInstallNecessaryPlugins(StaplerRequest)} but only checks if everything is installed
* or if some plugins need updates or installation.
*
* This method runs without side-effect. I'm still requiring the ADMINISTER permission since
* XML file can contain various external references and we don't configure parsers properly against
* that.
*
* @since 1.483
*/
@RequirePOST
public JSONArray doPrevalidateConfig(StaplerRequest req) throws IOException {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
JSONArray response = new JSONArray();
for (Map.Entry<String,VersionNumber> p : parseRequestedPlugins(req.getInputStream()).entrySet()) {
PluginWrapper pw = getPlugin(p.getKey());
JSONObject j = new JSONObject()
.accumulate("name", p.getKey())
.accumulate("version", p.getValue().toString());
if (pw == null) { // install new
response.add(j.accumulate("mode", "missing"));
} else if (pw.isOlderThan(p.getValue())) { // upgrade
response.add(j.accumulate("mode", "old"));
} // else already good
}
return response;
}
代码示例来源:origin: jenkinsci/jenkins
dependencies.add(new JSONObject()
.element("name", attrs[0])
.element("version", attrs[1])
代码示例来源:origin: geoserver/geoserver
/**
* @param list the list of auth urls to serialize
* @return {@code null} if {@code list} is null, empty, or contains only null objects; the JSON
* array representation of {@code list} otherwise, with any null element stripped off.
*/
public static String toString(List<LayerIdentifierInfo> list) {
if (list == null || list.isEmpty()) {
return null;
}
JSONArray array = new JSONArray();
for (LayerIdentifierInfo id : list) {
if (id == null) {
continue;
}
JSONObject jsonId = new JSONObject();
jsonId.put(AUTHORITY, id.getAuthority());
jsonId.put(IDENTIFIER, id.getIdentifier());
array.add(jsonId);
}
if (array.size() == 0) {
// list was made of only null objects?
return null;
}
String serialized = array.toString();
return serialized;
}
}
代码示例来源:origin: geoserver/geoserver
/**
* @param list the list of layer identifiers to serialize
* @return {@code null} if {@code list} is null, empty or contains only null objects; the JSON
* array representation of {@code list} otherwise, with any null element stripped off.
*/
public static String toString(List<AuthorityURLInfo> obj) {
if (obj == null || obj.isEmpty()) {
return null;
}
JSONArray array = new JSONArray();
for (AuthorityURLInfo auth : obj) {
if (auth == null) {
continue;
}
JSONObject jsonAuth = new JSONObject();
jsonAuth.put(NAME, auth.getName());
jsonAuth.put(HREF, auth.getHref());
array.add(jsonAuth);
}
if (array.size() == 0) {
// list was made of only null objects?
return null;
}
String serialized = array.toString();
return serialized;
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override protected synchronized JSON data() {
JSONArray r = new JSONArray();
for (User u : modified) {
UserInfo i = users.get(u);
JSONObject entry = new JSONObject().
accumulate("id", u.getId()).
accumulate("fullName", u.getFullName()).
accumulate("url", u.getUrl()).
accumulate("avatar", i.avatar != null ? i.avatar : Stapler.getCurrentRequest().getContextPath() + Functions.getResourcePath() + "/images/" + iconSize + "/user.png").
accumulate("timeSortKey", i.getTimeSortKey()).
accumulate("lastChangeTimeString", i.getLastChangeTimeString());
Job<?,?> p = i.getJob();
if (p != null) {
entry.accumulate("projectUrl", p.getUrl()).accumulate("projectFullDisplayName", p.getFullDisplayName());
}
r.add(entry);
}
modified.clear();
return r;
}
代码示例来源:origin: jenkinsci/jenkins
pluginInfo.put("dependencies", Collections.emptyMap());
response.add(pluginInfo);
pluginInfo.put("dependencies", plugin.dependencies);
pluginInfo.put("website", plugin.wiki);
response.add(pluginInfo);
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONArray toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTValue argument: arguments) {
a.add(argument.toJSON());
}
return a;
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONArray toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTStage stage: stages) {
a.add(stage.toJSON());
}
return a;
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONArray toJSON() {
final JSONArray a = new JSONArray();
for (Map.Entry<ModelASTKey, ModelASTValue> entry: arguments.entrySet()) {
JSONObject o = new JSONObject();
o.accumulate("key", entry.getKey().toJSON());
o.accumulate("value", entry.getValue().toJSON());
a.add(o);
}
return a;
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONArray toJSON() {
final JSONArray a = new JSONArray();
for (Map.Entry<ModelASTKey, ModelASTMethodArg> entry: variables.entrySet()) {
JSONObject o = new JSONObject();
o.accumulate("key", entry.getKey().toJSON());
o.accumulate("value", entry.getValue().toJSON());
a.add(o);
}
return a;
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONArray toJSON() {
final JSONArray a = new JSONArray();
for (Map.Entry<ModelASTKey, ModelASTEnvironmentValue> entry: variables.entrySet()) {
JSONObject o = new JSONObject();
o.accumulate("key", entry.getKey().toJSON());
o.accumulate("value", entry.getValue().toJSON());
a.add(o);
}
return a;
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTStep child:children) {
a.add(child.toJSON());
}
return super.toJSON().accumulate("children", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTOption option : options) {
a.add(option.toJSON());
}
return new JSONObject().accumulate("options", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTBuildCondition condition: conditions) {
a.add(condition.toJSON());
}
return new JSONObject().accumulate("conditions", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTTrigger trigger: triggers) {
a.add(trigger.toJSON());
}
return new JSONObject().accumulate("triggers", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTBuildParameter parameter : parameters) {
a.add(parameter.toJSON());
}
return new JSONObject().accumulate("parameters", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTValue arg: args) {
a.add(arg.toJSON());
}
return new JSONObject().accumulate("name", name).accumulate("arguments", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTMethodArg arg: args) {
a.add(arg.toJSON());
}
return new JSONObject().accumulate("name", name).accumulate("arguments", a);
}
代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin
@Override
public JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTStep step: steps) {
a.add(step.toJSON());
}
return new JSONObject().accumulate("name", name).accumulate("steps", a);
}
内容来源于网络,如有侵权,请联系作者删除!