Search in sources :

Example 96 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project orientdb by orientechnologies.

the class OGraphSONUtility method vertexFromJson.

/**
   * Creates a vertex from GraphSON using settings supplied in the constructor.
   */
public Vertex vertexFromJson(final InputStream json) throws IOException {
    final JsonParser jp = jsonFactory.createParser(json);
    final JsonNode node = jp.readValueAsTree();
    return this.vertexFromJson(node);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 97 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project presto by prestodb.

the class JsonRowDecoder method decodeRow.

@Override
public boolean decodeRow(byte[] data, Map<String, String> dataMap, Set<FieldValueProvider> fieldValueProviders, List<DecoderColumnHandle> columnHandles, Map<DecoderColumnHandle, FieldDecoder<?>> fieldDecoders) {
    JsonNode tree;
    try {
        tree = objectMapper.readTree(data);
    } catch (Exception e) {
        return true;
    }
    for (DecoderColumnHandle columnHandle : columnHandles) {
        if (columnHandle.isInternal()) {
            continue;
        }
        @SuppressWarnings("unchecked") FieldDecoder<JsonNode> decoder = (FieldDecoder<JsonNode>) fieldDecoders.get(columnHandle);
        if (decoder != null) {
            JsonNode node = locateNode(tree, columnHandle);
            fieldValueProviders.add(decoder.decode(node, columnHandle));
        }
    }
    return false;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) DecoderColumnHandle(com.facebook.presto.decoder.DecoderColumnHandle) FieldDecoder(com.facebook.presto.decoder.FieldDecoder)

Example 98 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode 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 99 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project ratpack by ratpack.

the class DefaultConfigData method getAsConfigObject.

@Override
public <O> ConfigObject<O> getAsConfigObject(String pointer, TypeToken<O> type) {
    JsonNode node = pointer != null ? rootNode.at(pointer) : rootNode;
    if (node.isMissingNode()) {
        node = emptyNode;
    }
    try {
        JavaType javaType = objectMapper.getTypeFactory().constructType(type.getType());
        O value = objectMapper.readValue(new TreeTraversingParser(node, objectMapper), javaType);
        return new DefaultConfigObject<>(pointer, type, value);
    } catch (IOException ex) {
        throw Exceptions.uncheck(ex);
    }
}
Also used : TreeTraversingParser(com.fasterxml.jackson.databind.node.TreeTraversingParser) JavaType(com.fasterxml.jackson.databind.JavaType) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException)

Example 100 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project realm-java by realm.

the class RealmListNYTimesMultimediumDeserializer method deserialize.

@Override
public List<NYTimesMultimedium> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    RealmList<NYTimesMultimedium> list = new RealmList<>();
    TreeNode treeNode = jp.getCodec().readTree(jp);
    if (!(treeNode instanceof ArrayNode)) {
        return list;
    }
    ArrayNode arrayNode = (ArrayNode) treeNode;
    for (JsonNode node : arrayNode) {
        NYTimesMultimedium nyTimesMultimedium = objectMapper.treeToValue(node, NYTimesMultimedium.class);
        list.add(nyTimesMultimedium);
    }
    return list;
}
Also used : RealmList(io.realm.RealmList) TreeNode(com.fasterxml.jackson.core.TreeNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) NYTimesMultimedium(io.realm.examples.newsreader.model.entity.NYTimesMultimedium) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)879 Test (org.junit.Test)224 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)217 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)142 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)125 IOException (java.io.IOException)91 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)86 HashMap (java.util.HashMap)79 HttpGet (org.apache.http.client.methods.HttpGet)68 JsonException (jmri.server.json.JsonException)66 Deployment (org.activiti.engine.test.Deployment)66 ArrayList (java.util.ArrayList)62 InputStream (java.io.InputStream)55 StringEntity (org.apache.http.entity.StringEntity)54 ByteArrayInputStream (java.io.ByteArrayInputStream)51 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)49 Task (org.activiti.engine.task.Task)41 HttpPost (org.apache.http.client.methods.HttpPost)39 Map (java.util.Map)33 Tree (org.apache.jackrabbit.oak.api.Tree)30