Search in sources :

Example 11 with ObjectNode

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) JsonNode(org.codehaus.jackson.JsonNode)

Example 12 with ObjectNode

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;
}
Also used : Field(org.apache.avro.Schema.Field) ObjectNode(org.codehaus.jackson.node.ObjectNode) ArrayList(java.util.ArrayList)

Example 13 with ObjectNode

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode)

Example 14 with ObjectNode

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;
}
Also used : RpcMap(com.extjs.gxt.ui.client.data.RpcMap) ObjectNode(org.codehaus.jackson.node.ObjectNode) JsonNode(org.codehaus.jackson.JsonNode) RpcMap(com.extjs.gxt.ui.client.data.RpcMap) Map(java.util.Map) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 15 with ObjectNode

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());
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) JsonFactory(org.codehaus.jackson.JsonFactory) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

ObjectNode (org.codehaus.jackson.node.ObjectNode)97 ArrayNode (org.codehaus.jackson.node.ArrayNode)29 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)28 JsonNode (org.codehaus.jackson.JsonNode)22 GET (javax.ws.rs.GET)21 Path (javax.ws.rs.Path)18 Test (org.junit.Test)17 Produces (javax.ws.rs.Produces)12 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 IOException (java.io.IOException)7 StringWriter (java.io.StringWriter)5 JsonFactory (org.codehaus.jackson.JsonFactory)5 HelixDataAccessor (org.apache.helix.HelixDataAccessor)4 Span (org.apache.stanbol.enhancer.nlp.model.Span)4 DatasetImpl (org.eol.globi.service.DatasetImpl)4 Date (java.util.Date)3 TaskDriver (org.apache.helix.task.TaskDriver)3 WorkflowConfig (org.apache.helix.task.WorkflowConfig)3