本文整理了Java中org.activityinfo.json.Json.createNull()
方法的一些代码示例,展示了Json.createNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createNull()
方法的具体详情如下:
包路径:org.activityinfo.json.Json
类名称:Json
方法名:createNull
暂无
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
return Json.createNull();
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
return Json.createNull();
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public JsonValue toJson() {
return Json.createNull();
}
代码示例来源: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 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
@Override
public JsonValue toJson() {
JsonValue object = Json.createObject();
object.put("operation", operation.name());
object.put("permitted", permitted);
object.add("filter", filter.isPresent() ? Json.create(filter.get()) : Json.createNull());
return object;
}
代码示例来源: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
public void testSerializeNull() throws Exception {
JsonValue null1 = Json.createNull();
JsonValue null2 = Json.createNull();
JsonValue out = serializeDeserialize(null1);
assertJsonEquals(null1, out);
assertSame(null1, out);
assertSame(null2, out);
assertSame(Json.createNull(), out);
}
代码示例来源: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
public static JsonValue fromPropertyValue(Object propertyValue) {
if(propertyValue == null) {
return Json.createNull();
} else if(propertyValue instanceof EmbeddedEntity) {
return fromEmbeddedEntity(((EmbeddedEntity) propertyValue));
} else if(propertyValue instanceof List) {
List<Object> propertyValueList = (List<Object>) propertyValue;
JsonValue convertedList = Json.createArray();
for (Object propertyValueListItem : propertyValueList) {
convertedList.add(fromPropertyValue(propertyValueListItem));
}
return convertedList;
} else if(propertyValue instanceof String) {
return Json.create((String)propertyValue);
} else if(propertyValue instanceof Number) {
return Json.create(((Number) propertyValue).doubleValue());
} else if(propertyValue instanceof Boolean) {
return Json.create((Boolean) propertyValue);
} else {
throw new UnsupportedOperationException("type: " + propertyValue.getClass().getName());
}
}
}
代码示例来源:origin: bedatadriven/activityinfo
private NewFormRecordBuilder buildUpdate(TypedFormRecord instance) {
NewFormRecordBuilder update = new NewFormRecordBuilder();
update.setId(instance.getId().asString());
update.setParentRecordId(instance.getParentRecordId().asString());
for (Map.Entry<ResourceId, FieldValue> entry : instance.getFieldValueMap().entrySet()) {
String field = entry.getKey().asString();
if(!field.equals("classId")) {
if(entry.getValue() == null) {
update.setFieldValue(field, Json.createNull());
} else if(isSaveable(entry.getValue())){
update.setFieldValue(field, entry.getValue().toJson());
}
}
}
return update;
}
代码示例来源:origin: bedatadriven/activityinfo
Optional<FormRecord> record = form.get().get(ref.getRecordId());
if (record.isPresent()) {
JsonValue labelValue = Json.createNull();
代码示例来源:origin: bedatadriven/activityinfo
@JsOverlay
public void setFieldValue(ResourceId fieldId, FieldValue value) {
if(value == null) {
setFieldValue(fieldId.asString(), Json.createNull());
} else {
setFieldValue(fieldId.asString(), value.toJson());
}
}
代码示例来源:origin: bedatadriven/activityinfo
public RecordUpdate buildUpdate(Optional<RecordRef> parentRef) {
RecordUpdate update = new RecordUpdate();
update.setRecordId(inputModel.getRecordRef().getRecordId());
update.setFormId(inputModel.getRecordRef().getFormId());
if(parentRef.isPresent()) {
update.setParentRecordId(parentRef.get().getRecordId().asString());
}
for (FormTree.Node node : formTree.getRootFields()) {
FieldInput newInput = inputModel.get(node.getFieldId());
if(newInput.getState() == FieldInput.State.VALID) {
update.setFieldValue(node.getFieldId(), newInput.getValue());
} else if(existingValues.containsKey(node.getFieldId()) &&
newInput.getState() == FieldInput.State.EMPTY) {
update.setFieldValue(node.getFieldId().asString(), Json.createNull());
} else if(existingValues.containsKey(node.getFieldId()) &&
!relevant.contains(node.getFieldId())) {
update.setFieldValue(node.getFieldId().asString(), Json.createNull());
}
}
return update;
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void updateSiteSetValueToBlank() throws JsonMappingException {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000001");
changeObject.setFormId(activityFormClass(1).asString());
changeObject.setFieldValue("BENE", Json.createNull());
changeObject.setFieldValue("comments", Json.createNull());
Updater updater = updater();
updater.executeChange(changeObject);
query(activityFormClass(1), "_id", "BENE", "comments");
assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003"));
assertThat(column("BENE"), hasValues(null, 3600, 10000));
assertThat(column("comments"), hasValues((String)null, null, null));
}
代码示例来源:origin: bedatadriven/activityinfo
public void testObjectNullValues() {
JsonValue object = Json.createObject();
object.put("a", (String)null);
object.put("b", Json.createNull());
assertTrue(object.get("a").isJsonNull());
assertTrue(object.get("b").isJsonNull());
assertTrue(object.get("c").isJsonNull());
}
代码示例来源: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
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
fieldValues.put(serialNumField.getName(), Json.createNull());
内容来源于网络,如有侵权,请联系作者删除!