Search in sources :

Example 6 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project tutorials by eugenp.

the class UserJsonDeserializer method deserialize.

@Override
public User deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser);
    TextNode favoriteColor = (TextNode) treeNode.get("favoriteColor");
    return new User(Color.web(favoriteColor.asText()));
}
Also used : TreeNode(com.fasterxml.jackson.core.TreeNode) TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 7 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project nuxeo-drive-server by nuxeo.

the class ScrollFileSystemItemListDeserializer method deserialize.

@Override
public ScrollFileSystemItemList deserialize(JsonParser jp, DeserializationContext dc) throws IOException {
    JsonNode rootNode = jp.readValueAsTree();
    String scrollId = ((TextNode) rootNode.get("scrollId")).textValue();
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode fileSystemItemNodes = (ArrayNode) rootNode.get("fileSystemItems");
    List<FileSystemItem> fileSystemItems = new ArrayList<>(fileSystemItemNodes.size());
    for (JsonNode fileSystemItemNode : fileSystemItemNodes) {
        boolean folderish = ((BooleanNode) fileSystemItemNode.get("folder")).booleanValue();
        if (folderish) {
            fileSystemItems.add(readValue(mapper, fileSystemItemNode, DocumentBackedFolderItem.class));
        } else {
            fileSystemItems.add(readValue(mapper, fileSystemItemNode, DocumentBackedFileItem.class));
        }
    }
    return new ScrollFileSystemItemListImpl(scrollId, fileSystemItems);
}
Also used : ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) BooleanNode(com.fasterxml.jackson.databind.node.BooleanNode) FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 8 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project nakadi by zalando.

the class EventTypeDbRepositoryTest method unknownAttributesAreIgnoredWhenDesserializing.

@Test
public void unknownAttributesAreIgnoredWhenDesserializing() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final ObjectNode node = (ObjectNode) TestUtils.OBJECT_MAPPER.readTree(TestUtils.OBJECT_MAPPER.writeValueAsString(eventType));
    node.set("unknown_attribute", new TextNode("will just be ignored"));
    final String eventTypeName = eventType.getName();
    final String insertSQL = "INSERT INTO zn_data.event_type (et_name, et_event_type_object) " + "VALUES (?, to_json(?::json))";
    template.update(insertSQL, eventTypeName, TestUtils.OBJECT_MAPPER.writeValueAsString(node));
    final EventType persistedEventType = repository.findByName(eventTypeName);
    assertThat(persistedEventType, notNullValue());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) TextNode(com.fasterxml.jackson.databind.node.TextNode) Test(org.junit.Test)

Example 9 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project syndesis by syndesisio.

the class ExtractConnectorDescriptorsMojo method addGav.

private void addGav(ObjectNode node, Artifact artifact) {
    TextNode gavNode = new TextNode(String.format("%s:%s:%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()));
    node.set("gav", gavNode);
}
Also used : TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 10 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project timbuctoo by HuygensING.

the class StringToUnencodedStringOfLimitedValuesConverter method tinkerpopToJson.

@Override
public TextNode tinkerpopToJson(Object value) throws IOException {
    if (value instanceof String) {
        JsonNode result = jsn((String) value);
        StringToEncodedStringOfLimitedValuesConverter.throwIfInvalid(result, this.allowedValues);
        return (TextNode) result;
    } else {
        throw new IOException("should be a string");
    }
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) IOException(java.io.IOException)

Aggregations

TextNode (com.fasterxml.jackson.databind.node.TextNode)96 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)35 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)28 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)15 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)14 IntNode (com.fasterxml.jackson.databind.node.IntNode)14 MockScheduler (org.apache.kafka.common.utils.MockScheduler)14 MockTime (org.apache.kafka.common.utils.MockTime)14 ExpectedTaskBuilder (org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder)14 ExpectedTasks (org.apache.kafka.trogdor.common.ExpectedTasks)13 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)12 NoOpTaskSpec (org.apache.kafka.trogdor.task.NoOpTaskSpec)11 ArrayList (java.util.ArrayList)9 Scheduler (org.apache.kafka.common.utils.Scheduler)9 MiniTrogdorCluster (org.apache.kafka.trogdor.common.MiniTrogdorCluster)9 CreateTaskRequest (org.apache.kafka.trogdor.rest.CreateTaskRequest)9 TaskRunning (org.apache.kafka.trogdor.rest.TaskRunning)9 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)8