Re: Can json-ld convert identifiers to IRIs?

On Jul 10, 2012, at 8:47 AM, Kuno Woudt wrote:

> Hello,
> 
> As I am writing the JSON for musicbrainz, I realized it could be a 
> problem that our identifiers aren't IRIs.
> 
> I'll give you an example.  A request to
> 
> http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=releases
> 
> can in the future return something like this (some properties omitted to 
> keep the example short):
> 
> {
>     "id": "fcbcdc39-8851-4efc-a02a-ab0e13be224f",
>     "title": "LAST ANGEL",
>     "length": 228106,
>     "releases": [
>         {
>             "id": "abcd76db-7d5f-3eb7-b386-051c97bfe2e4",
>             "title": "Kingdom"
>         }
>     ]
> }
> 
> Depending on what you pass in the inc= argument, deeper parts of the 
> graph may be returned.
> 
> To turn this into linked data the ids would somehow have to be turned 
> into full IRIs.  So fcbcdc39-8851-4efc-a02a-ab0e13be224f, which is a 
> recording would need to become:
> 
> http://musicbrainz.org/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f#_
> 
> And abcd76db-7d5f-3eb7-b386-051c97bfe2e4 should become
> 
> http://musicbrainz.org/release/abcd76db-7d5f-3eb7-b386-051c97bfe2e4#_

As Markus noted, @id references will be resolved against the document location, so if you were to make your identifier "fcbcdc39-8851-4efc-a02a-ab0e13be224f#_", it would likely resolve to "http://musicbrainz.org/release/abcd76db-7d5f-3eb7-b386-051c97bfe2e4#_".

There has been some discussion of @id processing, and this might be a use-case that could promote it. For more extensive changes, you might consider JSON-LD-Macros [1].

Depending on your usage, some custom client-side processing might not be too difficult. I work mostly with Backbone.js models, and this would be a fairly trivial modification when injesting the data into a model using a bit of custom JavaScript.

Alternatively, you could consider some server-side redirects.

Gregg

[1] https://github.com/antoniogarrote/json-ld-macros

> I fear this is a transformation which cannot be described in a 
> "@context", is that correct?  Any suggestions?
> 
> 
> -- kuno / warp.
> 
> ps. for those interested, the proposal is at [1], and is currently being 
> discussed on our developer mailinglist [2].
> [1] http://wiki.musicbrainz.org/User:kuno/Web_Service/JSON
> [2] http://wiki.musicbrainz.org/Mailing_Lists#Developers.27_Mailing_List
> 

Received on Wednesday, 11 July 2012 00:30:14 UTC