- From: Dave Longley <dlongley@digitalbazaar.com>
- Date: Wed, 25 Jun 2014 21:45:07 -0400
- To: Tomasz Pluskiewicz <tomasz@t-code.pl>, public-linked-json@w3.org
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]
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.
[1] http://www.w3.org/TR/json-ld-api/#flattening
--
Dave Longley
CTO
Digital Bazaar, Inc.
Received on Thursday, 26 June 2014 01:45:32 UTC