本文整理了Java中org.activityinfo.json.Json
类的一些代码示例,展示了Json
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json
类的具体详情如下:
包路径:org.activityinfo.json.Json
类名称:Json
[英]Vends out implementation of JsonFactory.
[中]出售JsonFactory的实现。
代码示例来源: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
public JsonValue parse(String json) {
return Json.parse(json);
}
代码示例来源: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() {
if(Double.isNaN(value)) {
return Json.createNull();
} else {
return Json.create(value);
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue getParametersAsJson() {
JsonValue object = createObject();
object.put("formId", classId == null ? Json.createNull(): Json.create(classId.asString()));
return object;
}
代码示例来源: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
@Override
public JsonValue toJson() {
JsonValue object = createObject();
object.put("downloadUrl", downloadUrl);
return object;
}
代码示例来源:origin: bedatadriven/activityinfo
public void testStringify() {
String json = "{\"a\":1,\"b\":\"hello\",\"c\":true,"
+ "\"d\":null,\"e\":[1,2,3,4],\"f\":{\"x\":1}}";
assertEquals(json, Json.stringify(Json.parse(json)));
}
代码示例来源:origin: bedatadriven/activityinfo
public void testSerializeObject() throws Exception {
JsonValue foo = Json.createObject();
foo.put("true", true);
foo.put("string", "string");
foo.put("number", 1.25);
JsonValue subObject = Json.createObject();
subObject.put("false", false);
subObject.put("string2", "string2");
subObject.put("number", -151);
JsonValue subArray = Json.createArray();
subArray.set(0, true);
subArray.set(1, 1);
subArray.set(2, "2");
foo.put("object", subObject);
foo.put("array", subArray);
foo.put("null", Json.createNull());
assertJsonEqualsAfterSerialization(foo);
}
代码示例来源: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
public void missingValue() throws JsonMappingException {
ResourceId fieldId = ResourceId.valueOf("Q1");
FormClass formClass = new FormClass(ResourceId.valueOf("XYZ123"));
formClass.addElement(new FormField(fieldId).setType(new QuantityType("meters")));
JsonValue fields = createObject();
fields.put("Q1", Json.createNull());
JsonValue change = createObject();
change.put("recordId", "A");
change.put("formId", "XYZ123");
change.put("fields", fields);
TypedRecordUpdate update = Updater.parseChange(formClass, change, userId);
assertTrue(update.getChangedFieldValues().containsKey(fieldId));
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
if(prefix == null) {
return Json.create(number);
} else {
JsonValue object = createObject();
object.put("prefix", prefix);
object.put("number", number);
return object;
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
return Json.createNull();
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
JsonValue object = createObject();
object.put("rowSources", Json.toJson(rowSources));
object.put("columns", Json.toJson(columns));
if(filter != null) {
object.put("filter", filter.asExpression());
}
if(!sortModels.isEmpty()) {
object.put("sort", Json.toJson(sortModels));
}
return object;
}
代码示例来源: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() {
return Json.create(text);
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public Promise<Void> updateRecords(RecordTransaction transaction) {
return post(RequestBuilder.POST, baseUrl + "/update", Json.stringify(transaction));
}
代码示例来源: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
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
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!