use of org.codehaus.jackson.node.ObjectNode in project openmrs-module-pihcore by PIH.
the class ConfigLoader method merge.
private static JsonNode merge(JsonNode mainNode, JsonNode updateNode) {
Iterator<String> fieldNames = updateNode.getFieldNames();
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
JsonNode jsonNode = mainNode.get(fieldName);
if (jsonNode != null && jsonNode.isObject()) {
merge(jsonNode, updateNode.get(fieldName));
} else {
((ObjectNode) mainNode).put(fieldName, updateNode.get(fieldName));
}
}
return mainNode;
}
use of org.codehaus.jackson.node.ObjectNode in project incubator-gobblin by apache.
the class FieldAttributeBasedDeltaFieldsProvider method getDeltaFieldNamesForNewSchema.
private List<String> getDeltaFieldNamesForNewSchema(Schema originalSchema) {
List<String> deltaFields = new ArrayList<>();
for (Field field : originalSchema.getFields()) {
String deltaAttributeField = field.getJsonProp(this.attributeField).getValueAsText();
ObjectNode objectNode = getDeltaPropValue(deltaAttributeField);
if (objectNode == null || objectNode.get(this.deltaPropName) == null) {
continue;
}
if (Boolean.parseBoolean(objectNode.get(this.deltaPropName).toString())) {
deltaFields.add(field.name());
}
}
log.info("Will use delta fields: " + deltaFields);
return deltaFields;
}
use of org.codehaus.jackson.node.ObjectNode in project activityinfo by bedatadriven.
the class PoEditorClient method getTerms.
public Map<String, PoTerm> getTerms(int projectId) throws IOException {
ObjectNode response = viewTerms(projectId, null);
PoTerm[] terms = objectMapper.readValue(response.path("list"), PoTerm[].class);
Map<String, PoTerm> map = new HashMap<>();
for (PoTerm term : terms) {
map.put(term.getKey(), term);
}
return map;
}
use of org.codehaus.jackson.node.ObjectNode in project activityinfo by bedatadriven.
the class RpcMapDeserializer method deserialize.
@Override
public RpcMap deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(jp);
RpcMap map = new RpcMap();
Iterator<Map.Entry<String, JsonNode>> fieldIt = root.getFields();
while (fieldIt.hasNext()) {
Map.Entry<String, JsonNode> field = fieldIt.next();
if (field.getValue().isNumber()) {
map.put(field.getKey(), field.getValue().getNumberValue());
} else if (field.getValue().isBoolean()) {
map.put(field.getKey(), field.getValue().asBoolean());
} else if (field.getValue().isTextual()) {
map.put(field.getKey(), field.getValue().asText());
}
}
return map;
}
use of org.codehaus.jackson.node.ObjectNode in project motech by motech.
the class MailDeserializerTest method getJsonParser.
private JsonParser getJsonParser(String from, String to, String subject, String text) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonFactory jsonFactory = new JsonFactory(mapper);
ObjectNode json = mapper.createObjectNode();
if (isNotBlank(from)) {
json.put(FROM_ADDRESS, from);
}
if (isNotBlank(to)) {
json.put(TO_ADDRESS, to);
}
if (isNotBlank(subject)) {
json.put(SUBJECT, subject);
}
if (isNotBlank(text)) {
json.put(MESSAGE, text);
}
return jsonFactory.createJsonParser(json.toString());
}
Aggregations