protected Object _deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { final TreeNode treeNode = p.readValueAsTree(); final TreeNode typeNode = treeNode.path("type"); if (!typeNode.isObject()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.START_OBJECT, "expected START_OBJECT before the type information and deserialized value"); } final TreeNode valueNode = typeNode.path("@value"); if (!valueNode.isValueNode()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.VALUE_STRING, "expected VALUE_STRING as type information and deserialized value"); } final JsonParser jsonParser = valueNode.traverse(); final String typeId = jsonParser.nextTextValue(); final JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); final JsonParser newParser = treeNode.traverse(); if (newParser.nextToken() != JsonToken.START_OBJECT) { ctxt.reportWrongTokenException(newParser, JsonToken.START_OBJECT, "expected START_OBJECT"); } return deser.deserialize(newParser, ctxt); } }
@Override public ContentAndMetadata deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); Preconditions.checkState(treeNode.isArray() && treeNode.size() >= 1, "The response should be an array with at least one element"); Preconditions.checkState(treeNode.get(0).isObject(), "The element should be a Json object"); ObjectNode node = (ObjectNode) treeNode.get(0); return ContentAndMetadata.from(ImmutableList.copyOf(node.fields()) .stream() .collect(Guavate.toImmutableMap(Entry::getKey, entry -> asListOfString(entry.getValue())))); }
/** * Set the function description of a transformation. Requires an object behind function_description. * * @param jp the current json parser * @param transformation the target {@code Transformation} * @throws IOException */ private static void setFunctionDescription(final JsonParser jp, final Transformation transformation) throws IOException { final TreeNode treeNode = jp.readValueAsTree(); if (treeNode.isObject()) { transformation.setFunctionDescription((com.fasterxml.jackson.databind.node.ObjectNode) treeNode); } else { throw JsonMappingException.from(jp, String.format( "Cannot parse the function description for the Transformation [%s], because it is not a Json Object", transformation)); } }
if (referenceNode != null && referenceNode.isObject()) { TreeNode serviceIdNode = containerNode.get("serviceId"); if (serviceIdNode == null) {
private void hash(TreeNode node) { if (node.isArray()) { md.update((byte)'l'); for (int i = 0; i < node.size(); i++) { hash(node.get(i)); } md.update((byte)'e'); } else if (node.isObject()) { String[] fieldNames = new String[node.size()]; Iterator<String> it = node.fieldNames(); for (int i=0; i< fieldNames.length; i++) { fieldNames[i] = it.next(); } Arrays.sort(fieldNames); md.update((byte)'d'); for (String fName : fieldNames) { hash(fName); hash(node.get(fName)); } md.update((byte)'e'); } else if (node.isValueNode()) { String val = ((JsonNode)node).textValue(); if (val != null) { hash(val); } } else { throw new IllegalArgumentException(node.toString()); } }
transform(root.get(i)); } else if (root.isObject()) { transform(root); } else {
treeWalk(parentIRI, parentClass, path + ":" + i, predicatePath, label, i, node.get(i)); } else if (node.isObject()) { IRI pkIRI = vf.createIRI((parentIRI == null ? "" : parentIRI.stringValue()) + path); IRI classIRI = vf.createIRI(baseURI + predicatePath + ":Node");