Search in sources :

Example 11 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.

the class EnvironmentConfigSource method loadConfigData.

@Override
public ObjectNode loadConfigData(ObjectMapper objectMapper, FileSystemBinding fileSystemBinding) throws Exception {
    ObjectNode rootNode = objectMapper.createObjectNode();
    serverEnvironment.getenv().entrySet().stream().map(toPair()).flatMap(getFilterFunc()).map(getPairTokenizerFunc()).forEach(entry -> {
        populate(rootNode, mapPathSegments(entry), 0, entry.getRight());
    });
    return rootNode;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 12 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.

the class EnvironmentConfigSource method populate.

private void populate(ObjectNode node, List<String> path, int pathIndex, String value) {
    String segment = path.get(pathIndex);
    if (pathIndex == path.size() - 1) {
        node.set(segment, TextNode.valueOf(value));
    } else {
        // For environment variables, we don't support array indexing.
        // Thus, if there are remaining segments, it must mean that the parent is an object.
        ObjectNode childNode = (ObjectNode) node.get(segment);
        if (childNode == null) {
            childNode = node.putObject(segment);
        }
        populate(childNode, path, pathIndex + 1, value);
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 13 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.

the class ObjectConfigSource method loadConfigData.

@Override
public ObjectNode loadConfigData(ObjectMapper mapper, FileSystemBinding fileSystemBinding) throws Exception {
    JsonNode value = mapper.valueToTree(object);
    ObjectNode root = mapper.createObjectNode();
    String[] keys = path.split("\\.");
    Iterator<String> iterator = Arrays.asList(keys).iterator();
    ObjectNode node = root;
    while (true) {
        String key = iterator.next();
        if (iterator.hasNext()) {
            node = node.putObject(key);
        } else {
            node.set(key, value);
            break;
        }
    }
    return root;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 14 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project spring-security-oauth by spring-projects.

the class FacebookController method photos.

@RequestMapping("/facebook/info")
public String photos(Model model) throws Exception {
    ObjectNode result = facebookRestTemplate.getForObject("https://graph.facebook.com/me/friends", ObjectNode.class);
    ArrayNode data = (ArrayNode) result.get("data");
    ArrayList<String> friends = new ArrayList<String>();
    for (JsonNode dataNode : data) {
        friends.add(dataNode.get("name").asText());
    }
    model.addAttribute("friends", friends);
    return "facebook";
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project flink by apache.

the class JSONKeyValueDeserializationSchema method deserialize.

@Override
public ObjectNode deserialize(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException {
    if (mapper == null) {
        mapper = new ObjectMapper();
    }
    ObjectNode node = mapper.createObjectNode();
    node.set("key", mapper.readValue(messageKey, JsonNode.class));
    node.set("value", mapper.readValue(message, JsonNode.class));
    if (includeMetadata) {
        node.putObject("metadata").put("offset", offset).put("topic", topic).put("partition", partition);
    }
    return node;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)767 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)185 JsonNode (com.fasterxml.jackson.databind.JsonNode)165 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)165 Test (org.junit.Test)112 StringEntity (org.apache.http.entity.StringEntity)88 Deployment (org.activiti.engine.test.Deployment)84 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)67 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)64 Task (org.activiti.engine.task.Task)49 HttpPost (org.apache.http.client.methods.HttpPost)49 JCodeModel (com.sun.codemodel.JCodeModel)45 JPackage (com.sun.codemodel.JPackage)44 IOException (java.io.IOException)43 HttpPut (org.apache.http.client.methods.HttpPut)40 JType (com.sun.codemodel.JType)39 HashMap (java.util.HashMap)39 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)39 ArrayList (java.util.ArrayList)32 Map (java.util.Map)32