Re: extracting frame from existing JSON-LD document?

On 12/08/2013 08:34 PM, Manu Sporny wrote:
> Elf, keep in mind that the framing document concept is not a
> standardized part of JSON-LD, so things could change over the next year
> or so. That said, there are several organizations (including ours) that
> use JSON-LD framing as implemented in the reference libraries in
> production systems.
> 
> On 12/08/2013 07:57 PM, ☮ elf Pavlik ☮ wrote:
>> * can one extract from it frame which framing algorithm used to form
>>  it?
> 
> No, framing documents are conceptually separate from JSON-LD data
> documents. However, you could create a JSON-LD frame from a JSON-LD data
> document pretty easily. You'd do this by cloning the JSON document and
> processing it a bit to create a frame (adding embedOn and explicitOn and
> stuff like that).
> 
> Dave Longley would have the details of how you could do this, but he's
> really busy these days and might miss this email.

Elf, JSON-LD frames were designed to look very similar to a template for
a document, so creating one from an existing document shouldn't be too
hard. I'm not aware of any existing libraries that will do this for you.
The process would be pretty much what Manu suggested it would be:
cloning the document and then experimenting/tweaking it until it works
the way you'd like.

The current framing implementation does duck-type or @type-based
matching. This means that if a subject has the properties (or @type)
specified in a frame, then that subject will be laid out using the same
structure that the frame uses. There are some other flags that Manu
mentioned (@embed, @explicit) that can be used to try and force nodes to
be embedded in certain places or to only include properties explicitly
found in the frame when outputting the "framed data."

Good luck!

-- 
Dave Longley
CTO
Digital Bazaar, Inc.

Received on Monday, 9 December 2013 17:17:17 UTC