w3c / activitystreams

Activity Streams 2.0
https://www.w3.org/TR/activitystreams-core/
Other
284 stars 60 forks source link

Object or Array property reference? #433

Closed francisli closed 6 years ago

francisli commented 6 years ago

Please Indicate One:

Please Describe the Issue:

Hello, I'm trying to understand how one should expect an object or array for a property. For example, the attachment property (https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment) is shown in Example 66 as having an array with one object:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Note",
  "name": "Have you seen my cat?",
  "attachment": [
    {
      "type": "Image",
      "content": "This is what he looks like.",
      "url": "http://example.org/cat.jpeg"
    }
  ]
}

I presume that this means that the attachment property can have multiple objects, correct? Would it be invalid to serialize this as simply an object? I.e:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Note",
  "name": "Have you seen my cat?",
  "attachment":  {
      "type": "Image",
      "content": "This is what he looks like.",
      "url": "http://example.org/cat.jpeg"
  }
}

The reason I ask is because other properties show this, such as preview (https://www.w3.org/TR/activitystreams-vocabulary/#dfn-preview) in Example 102:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Video",
  "name": "Cool New Movie",
  "duration": "PT2H30M",
  "preview": {
    "type": "Video",
    "name": "Trailer",
    "duration": "PT1M",
    "url": {
      "href": "http://example.org/trailer.mkv",
      "mediaType": "video/mkv"
    }
  }
}

Is it acceptable to have multiple previews referenced in an array?

In both cases, both attachment and preview, the Range is specified as simply "Object | Link". Are we to expect that for all properties with this Range, that they may either be a single object or an array of one or more objects?

Thanks for any clarification...

francisli commented 6 years ago

Nevermind, per the description of Properties:

Items not marked as "Functional" can have multiple values.

francisli commented 6 years ago

And, I'm seeing the effects of JSON-LD compaction here (from single object array to object), posting the link in case anyone else has similar questions:

https://www.w3.org/TR/json-ld-api/#compaction-algorithms