本文整理了Java中com.google.gson.JsonArray.forEach()
方法的一些代码示例,展示了JsonArray.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonArray.forEach()
方法的具体详情如下:
包路径:com.google.gson.JsonArray
类名称:JsonArray
方法名:forEach
暂无
代码示例来源:origin: gocd/gocd
@Override
public Filters deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final JsonObject j = json.getAsJsonObject();
final JsonElement filters = j.get(KEY_FILTERS);
if (null == filters) {
throw new JsonParseException("Missing filters array!");
}
final ArrayList<DashboardFilter> viewFilters = new ArrayList<>();
filters.getAsJsonArray().forEach((f) -> viewFilters.add(context.deserialize(f, DashboardFilter.class)));
return new Filters(viewFilters);
}
}
代码示例来源:origin: gocd/gocd
public static List<ConfigurationProperty> fromJSONArray(JsonReader jsonReader, String arrayKey) {
List<ConfigurationProperty> configurationProperties = new ArrayList<>();
jsonReader.readArrayIfPresent(arrayKey, properties -> {
properties.forEach(property -> {
JsonReader configPropertyReader = new JsonReader(property.getAsJsonObject());
ConfigurationProperty configurationProperty = fromJSON(configPropertyReader);
configurationProperties.add(configurationProperty);
});
});
return configurationProperties;
}
代码示例来源:origin: gocd/gocd
public static RoleConfig fromJSON(JsonReader jsonReader) {
RoleConfig model = new RoleConfig();
if (jsonReader == null) {
return model;
}
jsonReader.readArrayIfPresent("users", users -> {
users.forEach(user -> model.addUser(new RoleUser(user.getAsString())));
});
return model;
}
代码示例来源:origin: gocd/gocd
public static Tasks fromJSONArray(JsonReader jsonReader) {
Tasks allTasks = new Tasks();
jsonReader.readArrayIfPresent("tasks", tasks -> {
tasks.forEach(task -> {
allTasks.add(fromJSON(new JsonReader(task.getAsJsonObject())));
});
});
return allTasks;
}
代码示例来源:origin: gocd/gocd
public static ArtifactPropertiesConfig fromJSONArray(JsonReader jsonReader) {
ArtifactPropertiesConfig artifactPropertyConfigs = new ArtifactPropertiesConfig();
jsonReader.readArrayIfPresent("properties", properties -> {
properties.forEach(property -> {
artifactPropertyConfigs.add(PropertyConfigRepresenter.fromJSON(new JsonReader(property.getAsJsonObject())));
});
});
return artifactPropertyConfigs;
}
代码示例来源:origin: gocd/gocd
public static ParamsConfig fromJSONArray(JsonReader jsonReader) {
ParamsConfig paramConfigs = new ParamsConfig();
jsonReader.readArrayIfPresent("parameters", params -> {
params.forEach(param -> {
paramConfigs.add(ParamRepresenter.fromJSON(new JsonReader(param.getAsJsonObject())));
});
});
return paramConfigs;
}
代码示例来源:origin: gocd/gocd
private static void populateConfig(AdminsConfig config, JsonReader jsonReader) {
jsonReader.readArrayIfPresent("users", users -> users.forEach(user -> config.add(new AdminUser(new CaseInsensitiveString(user.getAsString())))));
jsonReader.readArrayIfPresent("roles", roles -> roles.forEach(role -> config.add(new AdminRole(new CaseInsensitiveString(role.getAsString())))));
}
}
代码示例来源:origin: gocd/gocd
public static Tabs fromJSONArray(JsonReader jsonReader) {
Tabs tabsConfig = new Tabs();
jsonReader.readArrayIfPresent("tabs", tabs -> {
tabs.forEach(tab -> {
tabsConfig.add(fromJSON(new JsonReader(tab.getAsJsonObject())));
});
});
return tabsConfig;
}
代码示例来源:origin: gocd/gocd
private static void setResources(JobConfig jobConfig) {
ResourceConfigs resourceConfigs = new ResourceConfigs();
jsonReader.readArrayIfPresent("resources", resources -> {
resources.forEach(resource -> {
resourceConfigs.add(new ResourceConfig(resource.getAsString()));
});
});
jobConfig.setResourceConfigs(resourceConfigs);
}
代码示例来源:origin: gocd/gocd
public static MaterialConfigs fromJSONArray(JsonReader jsonReader, ConfigHelperOptions options) {
MaterialConfigs materialConfigs = new MaterialConfigs();
jsonReader.readArrayIfPresent("materials", materials -> {
materials.forEach(material -> {
materialConfigs.add(MaterialRepresenter.fromJSON(new JsonReader(material.getAsJsonObject()), options));
});
});
return materialConfigs;
}
代码示例来源:origin: gocd/gocd
public static ArtifactPropertiesConfig fromJSONArray(JsonReader jsonReader) {
ArtifactPropertiesConfig artifactPropertyConfigs = new ArtifactPropertiesConfig();
jsonReader.readArrayIfPresent("properties", properties -> {
properties.forEach(property -> {
artifactPropertyConfigs.add(PropertyConfigRepresenter.fromJSON(new JsonReader(property.getAsJsonObject())));
});
});
return artifactPropertyConfigs;
}
代码示例来源:origin: gocd/gocd
public static PipelineScheduleOptions fromJSON(JsonReader jsonReader) {
PipelineScheduleOptions model = new PipelineScheduleOptions();
model.shouldPerformMDUBeforeScheduling(jsonReader.optBoolean("update_materials_before_scheduling").orElse(Boolean.TRUE));
jsonReader.readArrayIfPresent("materials", materials -> {
List<MaterialForScheduling> materialsForScheduling = new ArrayList<>();
materials.forEach(material -> materialsForScheduling.add(MaterialRevisionRepresenter.fromJSON(new JsonReader(material.getAsJsonObject()))));
model.setMaterials(materialsForScheduling);
});
model.setEnvironmentVariables(EnvironmentVariableRepresenter.fromJSONArray(jsonReader));
return model;
}
}
代码示例来源:origin: gocd/gocd
public static EnvironmentVariablesConfig fromJSONArray(JsonReader jsonReader) {
EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig();
jsonReader.readArrayIfPresent("environment_variables", environmentVariables -> {
environmentVariables.forEach(variable -> variables.add(EnvironmentVariableRepresenter.fromJSON(new JsonReader(variable.getAsJsonObject()))));
});
return variables;
}
代码示例来源:origin: gocd/gocd
public static Tasks fromJSONArray(JsonReader jsonReader) {
Tasks allTasks = new Tasks();
jsonReader.readArrayIfPresent("tasks", tasks -> {
tasks.forEach(task -> {
allTasks.add(fromJSON(new JsonReader(task.getAsJsonObject())));
});
});
return allTasks;
}
代码示例来源:origin: gocd/gocd
public static Filter fromJSON(JsonReader jsonReader) {
Filter filter = new Filter();
filter.clear();
jsonReader.readArrayIfPresent("ignore", ignoredFiles -> {
ignoredFiles.forEach(ignoredFile -> {
filter.add(new IgnoredFiles(ignoredFile.getAsString()));
});
});
return filter;
}
}
代码示例来源:origin: gocd/gocd
public static EnvironmentVariablesConfig fromJSONArray(JsonReader jsonReader) {
EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig();
jsonReader.readArrayIfPresent("environment_variables", environmentVariables -> {
environmentVariables.forEach(variable -> variables.add(EnvironmentVariableRepresenter.fromJSON(new JsonReader(variable.getAsJsonObject()))));
});
return variables;
}
代码示例来源:origin: gocd/gocd
public static AdminsConfig fromJSON(JsonReader jsonReader) {
AdminsConfig adminsConfig = new AdminsConfig();
jsonReader.readArrayIfPresent("users", users -> {
users.forEach(user -> adminsConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString()))));
});
jsonReader.readArrayIfPresent("roles", roles -> {
roles.forEach(role -> adminsConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString()))));
});
return adminsConfig;
}
代码示例来源:origin: gocd/gocd
private static void setJobs(JsonReader jsonReader, StageConfig stageConfig) {
JobConfigs allJobs = new JobConfigs();
jsonReader.readArrayIfPresent("jobs", jobs -> {
jobs.forEach(job -> {
allJobs.add(JobRepresenter.fromJSON(new JsonReader(job.getAsJsonObject())));
});
});
stageConfig.setJobs(allJobs);
}
}
代码示例来源:origin: gocd/gocd
private static void setStages(JsonReader jsonReader, PipelineConfig pipelineConfig) {
pipelineConfig.getStages().clear();
jsonReader.readArrayIfPresent("stages", stages -> {
stages.forEach(stage -> {
pipelineConfig.addStageWithoutValidityAssertion(StageRepresenter.fromJSON(new JsonReader(stage.getAsJsonObject())));
});
});
}
}
代码示例来源:origin: gocd/gocd
private static void setJobs(JsonReader jsonReader, StageConfig stageConfig) {
JobConfigs allJobs = new JobConfigs();
jsonReader.readArrayIfPresent("jobs", jobs -> {
jobs.forEach(job -> {
allJobs.add(JobRepresenter.fromJSON(new JsonReader(job.getAsJsonObject())));
});
});
stageConfig.setJobs(allJobs);
}
}
内容来源于网络,如有侵权,请联系作者删除!