Open goofballLogic opened 4 years ago
See https://codepen.io/goofballLogic/pen/VwYRRjx for example
var doc = [{
"@id": "http://test.com/1",
"http://test.com/name": [{
"@value": "hello"
}],
"http://test.com/nested": [{
"@id": "http://test.com/2",
"http://test.com/name": [{
"@value": "world"
}]
}]
}];
var docQuery = LD(doc, {});
var thing1 = docQuery.query("[@id=http://test.com/1]");
var thing2 = docQuery.query("[@id=http://test.com/2]");
output.textContent =
docQuery // object
+ " " + thing1 // object
+ " " + thing2 // null
;
When searching in a document for a node with arbitrary identity (e.g.
[@id=http://xyz.com]
) this will only match if the identified node is at the top of the queryied JSON.