RE: JSON-LD 1.0 - multiple values? [SEC=UNCLASSIFIED]

Hi Paul,

Thanks for your feedback. Comments inline below.

On Thursday, May 08, 2014 6:34 AM, Paul Murray wrote:
> I am having some difficulty navigating the standard with respect to an
> object having multiple values for the same predicate:
> 
> <rdf:Description rdf:about="#myObject">
>   <rdfs:seeAlso rdf:resource="#anotherObject1"/>
>   <rdfs:seeAlso rdf:resource="#anotherObject2"/>
> </rdf:Description>
> 
> After looking at the JSON-LD 1.0 Processing Algorithms and API, I have
> managed to work out that to do mutilple values for a predicate, you
> put them in an array. It's only if the expanded type of a key has
> @container that it's not treated as multiple values - it's treated as
> an RDF Collection.
> 
> It would be better if this was stated a bit more clearly in the main
> document - JSON-LD 1.0. The first mention of arrays in §3.1 "general
> terminology" gave me the impression that arrays are always rdf
> collections - it refers you to §6.11 Sets and Lists. I don't see
> anything up front to the effect that this only applies when there's a
> @container tag. None of the examples demonstrate this.

Well, it says explicitly that 

   "In JSON, an array is an ordered sequence of zero or more values. While
    JSON-LD uses the same array representation as JSON, the collection is
    unordered by default. While order is preserved in regular JSON arrays,
    it is not in regular JSON-LD arrays unless specifically defined (see
    section 6.11 Sets and Lists)."

If you click on that link to section 6.11 you get straight to "Example 42:
Multiple values with no inherent order". It then goes on to explain how
lists are expressed (Example 44: An ordered collection of values in JSON-LD,
Example 45: Specifying that a collection is ordered in the context).


> It would be good for there to be a section that explains that
> 
> {
>   "@id": "#myObject",
>   "@context": {
>     "bar": { @container =  @set }
>   },
>   "foo": [ {"@id"="a"},{"@id"="b"},{"@id"="c"} ],
>   "bar": [ {"@id"="a"},{"@id"="b"},{"@id"="c"} ]
> }
> 
> means
> 
> <rdf:Description rdf:about="#myObject">
>   <foo rdf:resource="a"/>
>   <foo rdf:resource="b"/>
>   <foo rdf:resource="c"/>
>   <bar rdf:parseType="Container">
>     <rdf:Description rdf:about="a"/>
>     <rdf:Description rdf:about="b"/>
>     <rdf:Description rdf:about="c"/>
>   </bar>
> </rdf:Description>

No, that's not true. "foo" and "bar" are completely equivalent in this case.
The only purpose of @set is to ensure that also sets consisting of just a
simple item remain arrays when compacting a JSON-LD document. Also that is
described in said section:

   "While @list is used to describe ordered lists, the @set keyword is
    used to describe unordered sets. The use of @set in the body of a
    JSON-LD document is optimized away when processing the document, as it
    is just syntactic sugar. However, @set is helpful when used within the
    context of a document. Values of terms associated with an @set or
    @list container are always represented in the form of an array, even
    if there is just a single value that would otherwise be optimized to a
    non-array form in compact form (see section 6.18 Compacted Document
    Form). This makes post-processing of JSON-LD documents easier as the
    data is always in array form, even if the array only contains a single
    value."

Have a look at the JSON-LD playground to see how things like these are
translated to triples.


HTH,
Markus


--
Markus Lanthaler
@markuslanthaler

Received on Saturday, 10 May 2014 12:30:32 UTC