-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON-LD parser does only find the first item #16
Comments
The commit closing this issue does not entirely fix this issue. The JSON LD implementation still does not find multiple items in case the value of Why? Because Did you ever think of writing some sort of "filter" option, so users can provide the type for which building up the graph should start? That way only returning one node would still be possible. I will try to write a test that demonstrates that only the graph of the first node gets returned. {
"@context": "http://schema.org",
"@graph": [
{
"@type": "Article",
"@id": "/articles/foobar",
"comment": [
{"@id": "/articles/foobar#comment-1"},
{"@id": "/articles/foobar#comment-2"}
]
},
{
"@type": "Comment",
"@id": "/articles/foobar#comment-1"
},
{
"@type": "Comment",
"@id": "/articles/foobar#comment-2"
}
]
} |
@rvanlaak Re-opening ... looking forward to any constructive suggestion! 👍 |
We for now added a custom JSON-LD parser that decorates the one of the library to support named graphs. Our domain depends on filtering on When class JsonLDFilteredParser extends JsonLD
{
public const FORMAT = 32;
protected function parseRootNode($jsonLDRoot)
{
// Test Named Graphs specification
if (!isset($jsonLDRoot->{'@graph'}, $jsonLDRoot->{'@context'})) {
return parent::parseRootNode($jsonLDRoot);
}
try {
$jsonDLDocument = JsonLDParser::getDocument($jsonLDRoot, ['documentLoader' => $this->contextLoader]);
/** @var GraphInterface $graph */
$graph = $jsonDLDocument->getGraph();
// Run through all nodes to parse the first one
foreach (FilterTypes::types as $type) {
$nodes = $graph->getNodesByType('http://schema.org/'.$type);
if (1 === \count($nodes)) {
$node = current($nodes);
return $this->parseNode($node);
}
}
} catch (JsonLdException $exception) {
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
}
return null;
}
} |
Same problem, here's an example: https://www.macobserver.com/news/apple-changes-testing-ios-14/ @rvanlaak Where is the |
|
Am 20.03.2017 um 13:59 schrieb Claas Kalwa:
Example source:
The text was updated successfully, but these errors were encountered: