本文整理了Java中net.sf.json.JSONArray.<init>()
方法的一些代码示例,展示了JSONArray.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.<init>()
方法的具体详情如下:
包路径:net.sf.json.JSONArray
类名称:JSONArray
方法名:<init>
暂无
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private JSONArray collectProblems(Map<Source, String> issues, String severity) {
final JSONArray problems = new JSONArray();
issues.entrySet().stream().map(e -> new JSONObject().accumulate("line", e.getKey().line).accumulate(severity, e.getValue()))
.forEach(problems::add);
return problems;
}
代码示例来源:origin: jenkinsci/jenkins
private JSONArray copyAndSanitizeArray(JSONArray jsonArray) {
JSONArray result = new JSONArray();
jsonArray.forEach(value ->
result.add(copyAndSanitize(value))
);
return result;
}
}
代码示例来源:origin: jenkinsci/jenkins
JSONArray dependencies = new JSONArray();
try {
Manifest m = new JarFile(t).getManifest();
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@RequirePOST
public void doCheck(StaplerRequest req, StaplerResponse res) throws Exception {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
res.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final Map<Source, String> issues = checkWith(new YamlSource<HttpServletRequest>(req, YamlSource.READ_FROM_REQUEST));
res.setContentType("application/json");
final JSONArray warnings = new JSONArray();
issues.entrySet().stream().map(e -> new JSONObject().accumulate("line", e.getKey().line).accumulate("warning", e.getValue()))
.forEach(warnings::add);
warnings.write(res.getWriter());
}
代码示例来源: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: 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
public HttpResponse doPlugins() {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
JSONArray response = new JSONArray();
Map<String,JSONObject> allPlugins = new HashMap<>();
for (PluginWrapper plugin : plugins) {
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
json.accumulate("version", p.version);
json.accumulate("url", url);
json.accumulate("dependencies", new JSONArray());
代码示例来源: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 (Map.Entry<ModelASTKey, ModelASTValue> entry: tools.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 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 JSONObject toJSON() {
final JSONArray a = new JSONArray();
for (ModelASTValue v : libs) {
a.add(v.toJSON());
}
return new JSONObject().accumulate("libraries", 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 (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 (ModelASTStep step: steps) {
a.add(step.toJSON());
}
return new JSONObject().accumulate("name", name).accumulate("steps", 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);
}
内容来源于网络,如有侵权,请联系作者删除!