Re: Design rationale behind the current schema for Facebook Open Graph Protocol

On Sat, 01 May 2010 17:35:30 -0400
Peter Mika <pmika@yahoo-inc.com> wrote:

> Would you take a crack at it? In a similar fashion, an OGP to JSON 
> mapping would be also highly desirable, otherwise implementations
> will diverge on the JSON serialization.

At http://srv.buzzword.org.uk/opengraph-to-json.html I do the following:

1. Parse the input document as RDFa;

2. Create a new, empty associative array called $RV.

3. Run a query equivalent to:

   SELECT $predicate $object
   WHERE {
     <> $predicate $object .
     FILTER(!isBlank($object))
   }

4. For each row of results:

    If $predicate is in the OGP namespace, trim the OGP namespace away;

    If $RV[$predicate] is not defined, set it to an empty array;

    If $RV[$object] is a URI, push it onto the array $RV[$predicate];

    If $RV[$object] is a literal, push the plain value onto the array
    $RV[$predicate].

5. Return $RV as JSON.

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>

Received on Wednesday, 5 May 2010 13:50:32 UTC