On 25/04/07, Kake L Pugh kake@earth.li wrote:
On Tue 24 Apr 2007, Earle Martin openguides@downlode.org wrote:
I'm looking forward to flying the OG flag at RoCoCoCamp as well as a long-overdue serious RDF talk with Evan.
Do you know if he's been thinking about outputs other than RDF? I was wondering if OpenGuides should perhaps have additional output formats that are a little more programmer-friendly - maybe JSON? These could be optional depending on whether the admin has the relevant Perl modules installed.
We haven't talked about specific formats per se; what we're mostly interested in is coordinating namespace usage. I've certainly got nothing against JSON output, and it might even be nice to offer N-Triples (http://www.w3.org/TR/rdf-testcases/#ntriples) as well. Your recent change to using templates for the output theoretically makes it very easy for us to implement.
Some examples of our output in different formats using Dave Beckett's excellent "triplr" triple-converter:
http://triplr.org/json;pretty/http://london.openguides.org/index.cgi?id=Roya... http://triplr.org/ntriples/http://london.openguides.org/index.cgi?id=Royal_A...
On Wed 25 Apr 2007, Earle Martin openguides@downlode.org wrote:
Your recent change to using templates for the output theoretically makes it very easy for us to implement.
We don't even need templates for JSON output; there's a Perl module (called JSON, unsurprisingly) that turns a Perl object directly into JSON.
Some examples of our output in different formats using Dave Beckett's excellent "triplr" triple-converter:
http://triplr.org/json;pretty/http://london.openguides.org/index.cgi?id=Roya...
Hm, that's not really what I meant by JSON output. That's RDF output wearing different clothes. What I was thinking of was something along these lines:
{ "name" : "Red Lion and Sun, N6 4BE", "uri" : "http://london.randomness.org.uk/wiki.cgi?id=Red_Lion_And_Sun,_N6_4BE;format=..." "wgs84_lat" : 51.572545, "wgs84_long" : -0.148517, "locales" : [ "Highgate", "N6" ], "categories" : [ "Pubs", "Pub Food", "Beer Gardens" ], }
Something that can trivially be turned back into an object without the need to parse RDF and work out what all the triples represent.
Or even:
{ "name" : "Red Lion and Sun, N6 4BE", "uri" : "http://london.randomness.org.uk/wiki.cgi?id=Red_Lion_And_Sun,_N6_4BE;format=..." "wgs84_lat" : 51.572545, "wgs84_long" : -0.148517, "locales" : [ "Highgate", "N6" ], "categories" : [ "Pubs", "Pub Food", "Beer Gardens" ], "nearby" : [ { "distance" : 153, "uri" : "http://london.randomness.org.uk/wiki.cgi?id=Wrestlers,_N6_4AA;format=json" }, { "distance" : 311, "uri" : "http://london.randomness.org.uk/wiki.cgi?id=Flask,_N6_6BU;format=json" }, { "distance" : 589, "uri" : "http://london.randomness.org.uk/wiki.cgi?id=Highgate_Station;format=json" } ] }
Kake
On 25/04/07, Kake L Pugh kake@earth.li wrote:
Hm, that's not really what I meant by JSON output. That's RDF output wearing different clothes.
Ah, I'm so used to thinking of RDF as RDF/XML.
What I was thinking of was something along these lines:
[snip]
Something that can trivially be turned back into an object without the need to parse RDF and work out what all the triples represent.
Kind of like YAML, right? A serialization format, I think they call it. Sure, absolutely. The more output, the merrier.
On Apr 25, 2007, at 9:32 AM, Kake L Pugh wrote:
On Wed 25 Apr 2007, Earle Martin openguides@downlode.org wrote:
Your recent change to using templates for the output theoretically makes it very easy for us to implement.
We don't even need templates for JSON output; there's a Perl module (called JSON, unsurprisingly) that turns a Perl object directly into JSON.
There is JSON::Any which (attempts) to normalize the APIs of the half dozen JSON modules on CPAN.
*cough* and patches in Trac that I think implement this for a sufficiently old version of OG.
Though I'm not sure how much of this works the way you want. I wrote it at Nacho's request for the Victoria Guide.
-Chris
On Wed 25 Apr 2007, Chris Prather chris@prather.org wrote:
There is JSON::Any which (attempts) to normalize the APIs of the half dozen JSON modules on CPAN.
Hm, I'm trying to work out if that would actually help us or not - I can see it would definitely help if we added a JSON dependency, but I was thinking along the lines of only sending out JSON output if we could find a JSON module. I suppose we could refuse to do JSON unless JSON::Any was installed... that might be the best bet.
*cough* and patches in Trac that I think implement this for a sufficiently old version of OG.
I think that assuming we use JSON::Any, the hard part is not going to be actually implementing this, but deciding what should go into the JSON output for each thing - e.g. the node output from my previous mail - what's useful/relevant? There should also be JSON output for categories and locales, listing everything in that category/locale. The main question, I think, is how much info we put into each mouthful of output; for example, the output for "Category Pubs" could be as simple as a list of format=json URLs; someone wanting more info could then fetch each URL individually and get the data from there - but that's a lot of hits on the webserver. We might be able to avoid some of those hits by returning more info in the Category Pubs JSON object, for example the name of the node, the other categories that it's in, its lat/long, its locales. This would be at the expense of more database activity on the original request.
</braindump>
Kake
openguides-dev@lists.openguides.org