W3C home > Mailing lists > Public > public-linked-json@w3.org > June 2014

Re: Flattening in jsonld.js

From: Tomasz Pluskiewicz <tomasz@t-code.pl>
Date: Thu, 26 Jun 2014 11:04:28 +0200
Message-ID: <CAAFOhSdrELMzRYXZX=y8rV9gZwmo74Sm-shyEf8ihrpSnug-EQ@mail.gmail.com>
To: Dave Longley <dlongley@digitalbazaar.com>
Cc: Tomasz Pluskiewicz <tomasz@t-code.pl>, public-linked-json@w3.org
On Thu, Jun 26, 2014 at 3:45 AM, Dave Longley
<dlongley@digitalbazaar.com> wrote:
> On 06/25/2014 01:37 PM, Tomasz Pluskiewicz wrote:
>> Hi
>>
>> The documentation for the flattening algorithm says that its output
>> always contains the @graph property. And so the playground does indeed
>> work that way.
>
> The @graph property is only always present for compacted, flattened
> output. That occurs when a context is given the flatten API.
>
> "Please note that the result of flattening and compacting a document is
> always a JSON object which contains an @graph member that represents the
> default graph." [1]
>

Ah I actually misunderstood that sentence because I didn't read the
whole section carefully. I thought it meant that both flattening and
compaction result in the presence of @graph. Only in the context I
realize it actually means doing one after another...

>
> If no context is given, then the output of the flatten API is an
> expanded, flattened document, which does not have to have @graph.
>
> The playground's flatten tab always uses a context so you see @graph
> there. If you delete the input entirely in the context text area, you
> can see "@graph" disappear in the output.
>
>>
>> However, I just got jsonld.js from Bower (that is version 0.2.13) and
>> for a document with a single graph it produces a flattened output
>> without the @graph similar to
>>
>> [
>>   {
>>     "@id": "resource one"
>>   },
>>   {
>>     "@id": "resource two"
>>   },
>>   {
>>     "@id": "resource three"
>>   }
>> ]
>>
>> Is this by design?
>
> The playground uses jsonld.js -- so it's just a matter of whether or not
> you're providing a context to the flatten call such that it triggers the
> compaction algorithm to run after flattening.
>

Indeed I do not pass a context. Thank you

>
> [1] http://www.w3.org/TR/json-ld-api/#flattening
>
>
> --
> Dave Longley
> CTO
> Digital Bazaar, Inc.
>
Received on Thursday, 26 June 2014 09:06:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:41 UTC