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