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;
}
use of com.fasterxml.jackson.databind.JsonNode in project orientdb by orientechnologies.
the class OGraphSONUtility method edgeFromJson.
/**
* Creates an edge from GraphSON using settings supplied in the constructor.
*/
public Edge edgeFromJson(final JsonNode json, final Vertex out, final Vertex in) throws IOException {
final Map<String, Object> props = OGraphSONUtility.readProperties(json, true, this.hasEmbeddedTypes);
final Object edgeId = getTypedValueFromJsonNode(json.get(GraphSONTokens._ID));
final JsonNode nodeLabel = json.get(GraphSONTokens._LABEL);
// assigned an empty string edge label in cases where one does not exist. this gets around the requirement
// that blueprints graphs have a non-null label while ensuring that GraphSON can stay flexible in parsing
// partial bits from the JSON. Not sure if there is any gotchas developing out of this.
final String label = nodeLabel == null ? EMPTY_STRING : nodeLabel.textValue();
final Edge e = factory.createEdge(edgeId, out, in, label);
for (Map.Entry<String, Object> entry : props.entrySet()) {
// if (this.edgePropertyKeys == null || this.edgePropertyKeys.contains(entry.getKey())) {
if (includeKey(entry.getKey(), edgePropertyKeys, this.edgePropertiesRule)) {
e.setProperty(entry.getKey(), entry.getValue());
}
}
return e;
}
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);
}
use of com.fasterxml.jackson.databind.JsonNode in project jvm-serializers by eishay.
the class JacksonJsonTree method readMedia.
protected static Media readMedia(JsonNode node) {
Media media = new Media();
JsonNode bitrate = node.get("bitrate");
if (bitrate != null && !bitrate.isNull()) {
media.bitrate = bitrate.intValue();
media.hasBitrate = true;
}
media.copyright = node.path("copyright").textValue();
media.duration = node.path("duration").longValue();
media.format = node.path("format").textValue();
media.height = node.path("height").intValue();
media.player = Media.Player.valueOf(node.get("player").textValue());
ArrayNode personsArrayNode = (ArrayNode) node.get("persons");
int size = personsArrayNode.size();
List<String> persons = new ArrayList<String>(size);
for (JsonNode person : personsArrayNode) {
persons.add(person.textValue());
}
media.persons = persons;
media.size = node.get("size").intValue();
media.title = node.get("title").textValue();
media.uri = node.get("uri").textValue();
media.width = node.get("width").intValue();
return media;
}
use of com.fasterxml.jackson.databind.JsonNode in project buck by facebook.
the class AndroidLibraryAsAnnotationProcessorHostIntegrationTest method getOutputFile.
private Path getOutputFile(String targetName) {
try {
ProjectWorkspace.ProcessResult buildResult = workspace.runBuckCommand("targets", targetName, "--show-full-output", "--json");
buildResult.assertSuccess();
JsonNode jsonNode = objectMapper.reader().readTree(buildResult.getStdout()).get(0);
assert jsonNode.has("buck.outputPath");
return Paths.get(jsonNode.get("buck.outputPath").asText());
} catch (Exception e) {
fail(e.getMessage());
return Paths.get("");
}
}
Aggregations