use of com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class BaseBpmnJsonConverter method addFormProperties.
protected void addFormProperties(List<FormProperty> formProperties, ObjectNode propertiesNode) {
if (CollectionUtils.isEmpty(formProperties))
return;
ObjectNode formPropertiesNode = objectMapper.createObjectNode();
ArrayNode propertiesArrayNode = objectMapper.createArrayNode();
for (FormProperty property : formProperties) {
ObjectNode propertyItemNode = objectMapper.createObjectNode();
propertyItemNode.put(PROPERTY_FORM_ID, property.getId());
propertyItemNode.put(PROPERTY_FORM_NAME, property.getName());
propertyItemNode.put(PROPERTY_FORM_TYPE, property.getType());
if (StringUtils.isNotEmpty(property.getExpression())) {
propertyItemNode.put(PROPERTY_FORM_EXPRESSION, property.getExpression());
} else {
propertyItemNode.putNull(PROPERTY_FORM_EXPRESSION);
}
if (StringUtils.isNotEmpty(property.getVariable())) {
propertyItemNode.put(PROPERTY_FORM_VARIABLE, property.getVariable());
} else {
propertyItemNode.putNull(PROPERTY_FORM_VARIABLE);
}
if (StringUtils.isNotEmpty(property.getDatePattern())) {
propertyItemNode.put(PROPERTY_FORM_DATE_PATTERN, property.getDatePattern());
}
if (CollectionUtils.isNotEmpty(property.getFormValues())) {
ArrayNode valuesNode = objectMapper.createArrayNode();
for (FormValue formValue : property.getFormValues()) {
ObjectNode valueNode = objectMapper.createObjectNode();
valueNode.put(PROPERTY_FORM_ENUM_VALUES_NAME, formValue.getName());
valueNode.put(PROPERTY_FORM_ENUM_VALUES_ID, formValue.getId());
valuesNode.add(valueNode);
}
propertyItemNode.put(PROPERTY_FORM_ENUM_VALUES, valuesNode);
}
propertyItemNode.put(PROPERTY_FORM_REQUIRED, property.isRequired());
propertyItemNode.put(PROPERTY_FORM_READABLE, property.isReadable());
propertyItemNode.put(PROPERTY_FORM_WRITABLE, property.isWriteable());
propertiesArrayNode.add(propertyItemNode);
}
formPropertiesNode.put("formProperties", propertiesArrayNode);
propertiesNode.put(PROPERTY_FORM_PROPERTIES, formPropertiesNode);
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project jackson-databind by FasterXML.
the class NullSerializationTest method testCustomNullForTrees.
// #281
public void testCustomNullForTrees() throws Exception {
ObjectNode root = MAPPER.createObjectNode();
root.putNull("a");
// by default, null is... well, null
assertEquals("{\"a\":null}", MAPPER.writeValueAsString(root));
// but then we can customize it:
DefaultSerializerProvider prov = new MyNullProvider();
prov.setNullValueSerializer(new NullSerializer());
ObjectMapper m = new ObjectMapper();
m.setSerializerProvider(prov);
assertEquals("{\"a\":\"foobar\"}", m.writeValueAsString(root));
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.
the class StoredAsJsonTest method testJsonNodeFieldDeserialization.
@Test
public void testJsonNodeFieldDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("jsonNodeField", expected);
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getJsonNodeField()).isEqualTo(innerJsonNode);
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.
the class StoredAsJsonTest method testAnnotatedFieldWithDefaultNullDeserialization.
@Test
public void testAnnotatedFieldWithDefaultNullDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("annotatedFieldWithDefault", NullNode.getInstance());
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.
the class StoredAsJsonTest method testAnnotatedFieldWithDefaultDeserialization.
@Test
public void testAnnotatedFieldWithDefaultDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("annotatedFieldWithDefault", expected);
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
Aggregations