W3C home > Mailing lists > Public > public-schemaorg@w3.org > June 2015

Re: JSON-LD and multiple values

From: Gregg Kellogg <gregg@greggkellogg.net>
Date: Tue, 9 Jun 2015 07:50:21 -0700
Cc: Melvin Carvalho <melvincarvalho@gmail.com>, Manu Sporny <msporny@digitalbazaar.com>, "schema.org Mailing List" <public-schemaorg@w3.org>, Dan Brickley <danbri@google.com>
Message-Id: <5FB230B8-E618-4141-9C56-DA87E10E753F@greggkellogg.net>
To: "mfhepp@gmail.com" <mfhepp@gmail.com>
> On Jun 9, 2015, at 2:35 AM, mfhepp@gmail.com wrote:
> 
> Melvin:
> I might not have made my point clear: This is not a problem of not being able to represent an RDF structure in JSON-LD, but that 
> 
> 1. the correct pattern in JSON-LD (list/array) is different from the pattern in Turtle, RDFa, RDF/XML etc. (repetition of the same property) and
> 2. that naively using the pattern from the other syntaxes fails *silently* in JSON-LD (just the last value is recognized).

As others have pointed out, this is not a JSON-LD issue, per se, but a general case of JSON ambiguity, which IJSON addresses. IJSON did not exist when JSON-LD was being finalized, but the goals for JSON-LD were generally that it stick to IJSON requirements.

Indeed, the Linter does not note such issues (neither does it note HTML markup issues, in general), but I think it should, and I’m going to incorporate some additional tools to note such problems. The Ruby JSON gem, which the Linter relies upon) simply converts the JSON to native ruby using Hashes (dictionaries), Arrays, Strings, Numbers and Booleans; thus, duplicate entries are truncated. Most people working with JSON understand this (I believe), but people coming to JSON-LD without a background in JSON may not be aware of this, thus the propensity for using duplicated entries.

At this point, ensuring that tools such as the Linter and the Structured Data Testing Tool note such issues, and that documentation (and certainly examples) highlight this is probably the best route forward.

Gregg

> Try my two examples in the Google Structured Data Testing tool and you will see the difference.
> 
> Martin
> 
> -----------------------------------
> martin hepp  http://www.heppnetz.de
> mhepp@computer.org          @mfhepp
> 
> 
> 
> 
> 
> 
> 
>> On 09 Jun 2015, at 11:23, Melvin Carvalho <melvincarvalho@gmail.com> wrote:
>> 
>> 
>> 
>> On 9 June 2015 at 10:59, mfhepp@gmail.com <mfhepp@gmail.com> wrote:
>> Dear Gregg,
>> dear Manu:
>> 
>> I think there is a need for clarifying the proper use of multiple values for the same property in JSON-LD because if I understand it properly, the behavior differs from any other RDF syntax and Microdata (see [1]), as you CANNOT simply repeat a property with different values, as in any other RDF syntax, like so
>> 
>> I thought all RDF can be converted to JSON LD?
>> 
>> JSON-LD is capable of serializing any RDF graph or dataset and most, but not all, JSON-LD documents can be directly interpreted as RDF as described in RDF 1.1 Concepts [RDF11-CONCEPTS].
>> 
>> http://www.w3.org/TR/json-ld/#relationship-to-rdf
>> 
>> 
>> 
>> <script type="application/ld+json">
>> {
>>  "@context": "http://schema.org",
>>  "@type": "Offer",
>>  "businessFunction" : "http://purl.org/goodrelations/v1#Repair",
>>  "businessFunction" : "http://purl.org/goodrelations/v1#Sell"
>> 
>> }
>> </script>
>> 
>> but instead must use a LIST of values, like so:
>> 
>> 
>> <script type="application/ld+json">
>> {
>>  "@context": "http://schema.org",
>>  "@type": "Offer",
>>  "businessFunction": ["http://purl.org/goodrelations/v1#Repair", "http://purl.org/goodrelations/v1#Sell" ]
>> 
>> }
>> </script>
>> 
>> The Google Structured Data Testing Tool shows only the value for the last use of the same property name, but in complex data structures, this will be easy to overlook.
>> 
>> We should highlight this prominently (and review all of our examples in schema.org), because otherwise people will have a hard time understanding why only part of their data is understood.
>> 
>> In particular, product feature markup with many usages of "additionalProperty" will be prone to this.
>> 
>> Best
>> 
>> Martin
>> 
>> [1] http://webmasters.stackexchange.com/questions/81080/using-productontology-org-to-add-multiple-types/81081#81081
>> 
>> 
>> -----------------------------------
>> martin hepp  http://www.heppnetz.de
>> mhepp@computer.org          @mfhepp
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
Received on Tuesday, 9 June 2015 14:50:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 9 June 2015 14:50:54 UTC