Hi, looking at your docs, there is some support for JSON-LD, but I cannot figure out how to use it properly. I checked out https://github.com/digitalbazaar/jsonld.js, and like the way I can take a POJ (Plain Old JSON) and add a header with link to context file and turn that POJ into linked data, which I can then persist in Stardog. Equally I would like to query for a resource (you guys already support that largely via the DESCRIBE command support), but instead of returning the JSON output with listed attributes, I would love to see a POJ returned, with link content, either as part of same returned POJ or as a header. Does this make sense to do? What I am really saying is that I want to persist a POJ easily in stardog.
--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
[ { "attributes": { "http://accounts.com#hasOverdraft": [ { "@value": 500 } ], "@type": [ "http://accounts.com#CurrentAccount", "http://www.w3.org/2002/07/owl#NamedIndividual" ], "http://accounts.com#hasSortCode": [ { "@value": "01-01-01" } ], "http://accounts.com#hasAccountNumber": [ { "@type": "http://www.w3.org/2001/XMLSchema#string", "@value": "00000001" } ], "@id": "http://accounts.com#BarclaysCurrentAccount01", "http://accounts.com#isPartOf": [ { "@id": "http://accounts.com#AlexBatlinPortfolio01" } ] } } ]
I can process that as such :
data.forEach(function(item) {
jsonld.compact(item.attributes, context, function(err, compacted) {
res.json(compacted);
});
})
And then it works, but I am trying to figure out the rational (I am pretty sure I am missing something) for this type of output. Any thoughts will be most welcome. Here is the query issue code:
var stardog = require("stardog");
var jsonld = require('jsonld');
var conn = new stardog.Connection();
var context = {
"overDraft": "http://accounts.com#hasOverdraft",
"sortCode": "http://accounts.com#hasSortCode",
"portfolio": "http://accounts.com#isPartOf",
"accountNumber": {
"@id": "http://accounts.com#hasAccountNumber",
"@type": "http://www.w3.org/2001/XMLSchema#string"
}
}
conn.setEndpoint("http://localhost:5820/");
conn.setCredentials("admin", "admin");
conn.setReasoning("SL");
exports.query = function (req, res) {
conn.queryGraph({
database: "accountsDB",
mimetype: "application/ld+json",
//query: "select distinct ?p ?o where { <http://accounts.com#BarclaysCurrentAccount01> ?p ?o }",
query: "construct { <http://accounts.com#BarclaysCurrentAccount01> ?p ?o } where { <http://accounts.com#BarclaysCurrentAccount01> ?p ?o }",
limit: 100,
offset: 0
},
function (data) {
// data.forEach(function(item) {
// jsonld.compact(item.attributes, context, function(err, compacted) {
// res.json(compacted);
// });
// })
res.json(data);
});
}
Many thanks,
Alex.
Cool, so I was totally crazy. Final question, how come the attributes return I got is inside an array (square brackets), rather than curly brackets. Reminder of what I got as a return:
[ { "attributes": { "http://accounts.com#hasOverdraft": [ { "@value": 500 } ], "@type": [ "http://accounts.com#CurrentAccount", "http://www.w3.org/2002/07/owl#NamedIndividual" ], "http://accounts.com#hasSortCode": [ { "@value": "01-01-01" } ], "http://accounts.com#hasAccountNumber": [ { "@type": "http://www.w3.org/2001/XMLSchema#string", "@value": "00000001" } ], "@id": "http://accounts.com#BarclaysCurrentAccount01", "http://accounts.com#isPartOf": [ { "@id": "http://accounts.com#AlexBatlinPortfolio01" } ] } } ]Would you expect any other list members, or do you always just get a list with one item, and if so why?
--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.