VIE.Util.rdf2Entities uses RDFQuery to convert rdf/json data (Talis format, not JSON-LD) into VIE.Entities. It is used by most of the services in the distribution. RDFQuery also contains an RDF-XML parser, so this method can easily be adapted to be used in the creation of VIE services that connect to dataset that return RDF-XML (a format which is more widely used than rdf/json, I think)
Regarding JSON-LD, I read in Entity.js: "VIE internally uses JSON-LD to store entities". So I thought that it should be possible to pass JSON-LD data to the constructor of Entity. But it seems that Entity.js uses @subject instead of @id for the URIs of the resources, cf:
var Model = Backbone.Model.extend({
idAttribute: '@subject',
initialize: function(attributes, options) {
if (attributes['@subject']) {
this.id = this['@subject'] = this.toReference(attributes['@subject']);
} else {
this.id = this['@subject'] = attributes['@subject'] = this.cid.replace('c', '_:bnode');
}
return this;
},
I modified these lines to:
var Model = Backbone.Model.extend({
idAttribute: '@subject',
initialize: function(attributes, options) {
if (attributes['@subject']) {
this.id = this['@subject'] = this.toReference(attributes['@subject']);
} else if (attributes['@id']) { // fps
this.id = this['@id'] = this.toReference(attributes['@id']);
} else {
this.id = this['@subject'] = attributes['@subject'] = this.cid.replace('c', '_:bnode');
}
return this;
},
Not really sure that this makes sense, but it seems that I can now create entities with JSON-LD data.
Best,
fps