I was thinking about how to use JSON-LD to control the application according to the HATEOAS principle.
For example, I could have a simple entrypoint object that defines a link:
{ "@context": { "users": { "@id": "http://example.com/onto#users", "@type": "@id" } }, "@id": "http://example.com/api", "users": "http://example.com/users" }
And the #users predicate will be defined as Link using Hydra:
{ "@context": "http://www.w3.org/ns/hydra/context.jsonld", "@id": "http://example.com/onto#users", "@type": "Link" }
Everything is still: the application retrieves the resource, then the onto#users resource will be dereferenced to detect semantics.
The question is how the developer should find the URI of the users property from the JSON-LD document. Of course, this is clearly defined in @context in my example, but this URI can be declared as QName:
"@context": { "onto": "http://example.com/onto#", "users": { "@id": "onto:users", "@type": "@id" } }
or an external context or multiple / nested contexts may be used.
Is there any functionality in the Javron JSON-LD library that will return absolute URIs of any property? Or is there an easy way to find it? A way that will work no matter how @context structured? Something like
var jsonLd = var usersUri = jsonLd.uriOf('users'); expect(usersUri).toBe('http://example.com/onto#users');
In other words, I think I'm looking for a single API to read @context .
angularjs rest hateoas
Tomasz Pluskiewicz
source share