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()));
}
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);
}
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());
}
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);
}
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");
}
}
Aggregations