本文整理了Java中org.activityinfo.json.Json.createArray()
方法的一些代码示例,展示了Json.createArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createArray()
方法的具体详情如下:
包路径:org.activityinfo.json.Json
类名称:Json
方法名:createArray
暂无
代码示例来源:origin: bedatadriven/activityinfo
private static JsonValue toArray(Object o) {
JsonValue array = Json.createArray();
int length = Array.getLength(o);
for (int i = 0; i < length; i++) {
array.add(toJson(Array.get(o, i)));
}
return array;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue array = Json.createArray();
for (Attachment value : values) {
array.add(value.toJsonElement());
}
return array;
}
代码示例来源:origin: bedatadriven/activityinfo
static JsonValue toJsonArray(Iterable<FormElement> elements) {
JsonValue elementsArray = Json.createArray();
for (FormElement element : elements) {
elementsArray.add(element.toJsonObject());
}
return elementsArray;
}
代码示例来源:origin: bedatadriven/activityinfo
public static JsonValue toJsonArray(Iterable<? extends JsonSerializable> objects) {
JsonValue array = Json.createArray();
for (JsonSerializable object : objects) {
array.add(object.toJson());
}
return array;
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
if(references.size() == 0) {
return Json.createNull();
} else if(references.size() == 1) {
return references.iterator().next().toJsonElement();
} else {
JsonValue array = Json.createArray();
for (RecordRef reference : references) {
array.add(reference.toJsonElement());
}
return array;
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
if(valueIds.isEmpty()) {
return Json.createNull();
} else if(valueIds.size() == 1) {
return Json.create(valueIds.iterator().next().asString());
} else {
JsonValue array = Json.createArray();
for (ResourceId valueId : valueIds) {
array.add(Json.create(valueId.asString()));
}
return array;
}
}
代码示例来源:origin: bedatadriven/activityinfo
private JsonValue toJson(Set<ResourceId> offlineForms) {
JsonValue array = Json.createArray();
for (ResourceId offlineForm : offlineForms) {
array.add(Json.create(offlineForm.asString()));
}
return array;
}
代码示例来源:origin: bedatadriven/activityinfo
public static JsonValue toJson(Object value) {
if(value instanceof JsonSerializable) {
return ((JsonSerializable) value).toJson();
} else if(value instanceof Collection) {
JsonValue array = Json.createArray();
for (Object element : ((Collection) value)) {
array.add(Json.toJson(element));
}
return array;
} else {
return JsonReflection.toJson(value);
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue opArray = Json.createArray();
for (Map.Entry<Operation, Optional<String>> op : operations.entrySet()) {
JsonValue opObject = Json.createObject();
opObject.add("operation", Json.create(op.getKey().name()));
opObject.add("filter", op.getValue().isPresent() ? Json.create(op.getValue().get()) : Json.createNull());
opArray.add(opObject);
}
JsonValue object = Json.createObject();
object.put("resourceId", resourceId.asString());
object.put("operations", opArray);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue object = Json.createObject();
object.put("pivotModel", pivotModel.toJson());
object.put("includeFolderLabels", includeFolderLabels);
if (includeFolderLabels) {
JsonValue array = Json.createArray();
folderMapping.entrySet().forEach(mapping -> {
JsonValue map = Json.createObject();
map.put("formId", mapping.getKey().asString());
map.put("folderLabel", mapping.getValue());
array.add(map);
});
object.put("folderMapping", array);
}
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue array = Json.createArray();
for (FormRecord record : records) {
array.add(record.toJson());
}
JsonValue object = Json.createObject();
object.put("formId", formId);
object.put("records", array);
return object;
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue getParametersAsJson() {
JsonValue enumValueArray = Json.createArray();
for (EnumItem enumItem : getValues()) {
enumValueArray.add(enumItem.toJsonObject());
}
JsonValue object = createObject();
object.put("cardinality", cardinality.name().toLowerCase());
object.put("presentation", presentation.name().toLowerCase());
object.put("values", enumValueArray);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue grantsArray = Json.createArray();
for (GrantModel grant : grants) {
grantsArray.add(grant.toJson());
}
JsonValue object = Json.createObject();
object.put("userId", userId);
object.put("databaseId", databaseId);
object.put("grants", grantsArray);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Value.Lazy
@Override
public JsonValue toJson() {
JsonValue measures = Json.createArray();
for (MeasureModel measureModel : getMeasures()) {
measures.add(measureModel.toJson());
}
JsonValue dimensions = Json.createArray();
for (DimensionModel dimensionModel : getDimensions()) {
dimensions.add(dimensionModel.toJson());
}
JsonValue object = Json.createObject();
object.put("measures", measures);
object.put("dimensions", dimensions);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue getParametersAsJson() {
JsonValue object = createObject();
object.put("cardinality", cardinality.name().toLowerCase());
JsonValue rangeArray = Json.createArray();
for (ResourceId formId : range) {
JsonValue rangeObject = createObject();
rangeObject.put("formId", formId.asString());
rangeArray.add(rangeObject);
}
object.put("range", rangeArray);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void deserializationCheckboxes() {
JsonValue object = createObject();
object.put("presentation", "CHECKBOX");
object.put("cardinality", "SINGLE");
object.put("values", Json.createArray());
EnumType enumType = EnumType.TYPE_CLASS.deserializeType(object);
assertThat(enumType.getPresentation(), equalTo(EnumType.Presentation.RADIO_BUTTON));
}
代码示例来源:origin: bedatadriven/activityinfo
@Test(expected = InvalidUpdateException.class)
public void newResourceWithoutClass() {
JsonValue change = createObject();
change.put("formId", "XYZ123-new-id");
JsonValue changes = Json.createArray();
changes.add(change);
JsonValue updateObject = createObject();
updateObject.put("changes", changes);
updater.execute(updateObject);
}
代码示例来源:origin: bedatadriven/activityinfo
@Value.Lazy
public JsonValue toJson() {
JsonValue object = Json.createObject();
object.put("id", getId());
object.put("label", getLabel());
object.put("formId", getFormId().asString());
object.put("formula", getFormula());
JsonValue statArray = Json.createArray();
for (Statistic statistic : getStatistics()) {
statArray.add(Json.create(statistic.name()));
}
object.put("statistics", statArray);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
@Test(expected = InvalidUpdateException.class)
public void newResourceWithMissingCollection() {
JsonValue change = createObject();
change.put("recordId", "XYZ123");
change.put("formId", "foobar");
JsonValue changes = Json.createArray();
changes.add(change);
JsonValue updateObject = createObject();
updateObject.put("changes", changes);
updater.execute(updateObject);
}
代码示例来源:origin: bedatadriven/activityinfo
@Test(expected = InvalidUpdateException.class)
public void newResourceWithInvalidClass() {
JsonValue change = createObject();
change.put("recordId", "XYZ123");
change.put("formId", createObject());
JsonValue changes = Json.createArray();
changes.add(change);
JsonValue updateObject = createObject();
updateObject.put("changes", changes);
updater.execute(updateObject);
}
内容来源于网络,如有侵权,请联系作者删除!