uber-hypermedia / specification

UBER Hypermedia Specification
http://uberhypermedia.org
24 stars 5 forks source link

Iterating over collection items in an uber message #4

Open inadarei opened 9 years ago

inadarei commented 9 years ago

From @dschulten on May 18, 2014 12:43

Hi,

a data element which contains collection items (people, todos) can also contain other items such as affordances to search or create, as shown by [1]. Question: is there a safe way to iterate over all collection items, excluding affordances which are not collection items themselves? Or to put it differently, how can I distinguish collection items from affordances which are not part of the collection? It might not be safe to assume that items with nested data are collection items, whereas others are not - although that seems to work with the examples at hand. Or is the existence of nested data exactly what distinguishes collection items from other affordances?

[1] https://rawgit.com/mamund/media-types/master/uber-hypermedia.html#_message_examples

Copied from original issue: mamund/media-types#42

inadarei commented 9 years ago

From @mamund on May 18, 2014 15:21

if i understand your Q....

1) just as in the way HTML works, you can make decisions about how to process individual elements based on their nesting context and/or as a stand-alone element.

2) if you want to exclude affordances in processing UBER documents, just ignore the ones that have an @url property

"It might not be safe to assume that items with nested data are collection items..." I am not sure I understand this statement. Can you expand a bit?

Cheers

mamund +1.859.757.1449 skype: mca.amundsen http://amundsen.com/blog/ http://twitter.com/mamund https://github.com/mamund http://linkedin.com/in/mamund

On Sun, May 18, 2014 at 8:43 AM, Dietrich Schulten <notifications@github.com

wrote:

Hi,

a data element which contains collection items (people, todos) can also contain other items such as affordances to search or create, as shown by [1]. Question: is there a safe way to iterate over all collection items, excluding affordances which are not collection items themselves? Or to put it differently, how can I distinguish collection items from affordances which are not part of the collection? It might not be safe to assume that items with nested data are collection items, whereas others are not - although that seems to work with the examples at hand. Or is the existence of nested data exactly what distinguishes collection items from other affordances?

[1] https://rawgit.com/mamund/media-types/master/uber-hypermedia.html#_message_examples

— Reply to this email directly or view it on GitHubhttps://github.com/mamund/media-types/issues/42 .