As Tomasz already suggested, you should really consider using Hydra as it does more or less what you want. The example you've included in your questions, would look somewhat like this using Hydra and JSON-LD:
{
"@context": {
"schema": "http://schema.org",
"ex": "http://example.com/myvocab#"
},
"@id": "/users/123",
"@type": [ "schema:Person", "hydra:Resource" ],
"name": "Jon Snow",
"ex:link": { "@id": "/another-resource" }
}
As there's no need for a "self" link (@id
already specifies that explicitly), I've added another link, ex:link
. Its link relation is consequently http://example.com/myvocab#link
and its "href" is /another-resource
. If you need to describe that link/property in more details, you can do so by creating a document which defines it in exactly the same manner as other things are described (as Tomasz also already explained):
{
"@context": {
"ex": "http://example.com/myvocab#",
"hydra": "http://www.w3.org/ns/hydra#"
},
"@id": "ex:link",
"@type": "hydra:Link",
"hydra:title": "My new link relation",
"hydra:supportedOperation": [
{
"@type": "hydra:Operation",
"hydra:method": "POST",
"hydra:expects": ....
}
]
}
Regarding your comment
Btw. I am more or less familiar with the Hydra vocab, but I don't like
the idea to map the resources to real classes and objects on a server
side language and automatically transform the operation parameters
into those objects. Maybe it is possible to use the Hydra vocab in
another way, but I don't have the time to experiment with that.
Hydra is really just a vocabulary. It is up to you to decide how to use it. I think you are talking about the HydraBundle above. That's just one way to use it. It is just a proof of concept to show that it is easily possible. So please don't get confused by that.
I would like to invite you to join the Hydra W3C Community Group. We can then discuss this in more detail on our mailing list.
Disclaimer: I'm the creator of Hydra and the chair of the Hydra W3C Community Group.