Skip to content

Instantly share code, notes, and snippets.

@pfrazee
Last active April 19, 2018 20:39
Show Gist options
  • Save pfrazee/f6030e59d335e73a3bcec77ca725b20d to your computer and use it in GitHub Desktop.
Save pfrazee/f6030e59d335e73a3bcec77ca725b20d to your computer and use it in GitHub Desktop.
@lachenmayer
Copy link

Thinking about this a bit more, I would strongly tend towards approach 2.

In code terms: If I want to get all the authors in the example object...

  • in approach 1, I'd have to do links.filter(link => link.rel === 'author') or some other trickery,
  • while in approach 2, I can just get links.author.

(I think this is exactly what @jondashkyle means by more easily addressable)

In human terms: If you already know how JSON works, you don't need to know what rel or href mean in approach 2. They are meaningless acronyms (...what do they even stand for?). If you need extra metadata, then sure, href is a good choice exactly because it's so meaningless. Giving every link a name/purpose will make it a lot easier to "standardize" on specific link types. I for one would want "author" (or even "donate"/"payment"!) links to be universally adopted across the beakerweb :)

@Treora
Copy link

Treora commented Apr 5, 2018

I may have missed the context, but am curious whether you are trying to have the links defined in dat.json be equivalent to Web Links as used in http headers (rfc8288)? Should one be able to convert between the two in either direction?

Some notes regarding making a consistent mapping with web links:

  • Is the context (the resource the link 'points from') always the root URI of the dat? Can one also define the anchor attribute to create a link from another resource? Might be a nice future addition, as it allows specifying links from resources within the dat (though you may also want to be able to define them in subfolders etc.).
  • Links may have multiple rels. This should not be a problem, as this is equivalent to multiple links, so in approach #2 you would simply duplicate the link for each rel.
  • This CoRE draft is all about mapping web links to json and cbor, so it may be worth borrowing their approach. Their json example looks equivalent to approach #1.
  • This article mentions a few other approaches for embedding links in json. Not all approaches seem to care about creating a consistent mapping with web links though.

@pfrazee
Copy link
Author

pfrazee commented Apr 19, 2018

Good feedback all, appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment