On 3/26/07, David Huynh <[EMAIL PROTECTED]> wrote:
> Lee Feigenbaum wrote:
> > Hi everyone,
> >
> > I'm wondering if there's a (easy) way to get the JSON for an Exhibit
> > database. That is, I'm looking for the equivalent of doing:
> >
> > [...]
>
> Try
>
>     Exhibit.ExhibitJsonExporter.exportMany(database.getAllItems(), database)

And it seems those on the 1.0.pre-ui-split branch should do:

exhibit.resolveURL = Exhibit.resolveURL;
database = exhibit.getDatabase();
var json = Exhibit.ExhibitJsonExporter.exportMany(database.getAllItems(),
exhibit);

Might not be the way it was designed to, but I arrived that after
experimenting for a while in Firebug with

try{Exhibit.ExhibitJsonExporter.exportMany(database.getAllItems(),
exhibit);}catch(e){e}

> which would give you a string. I actually am not sure whether the string
> is JSON proper. That exporter is implemented in
>
>
> http://simile.mit.edu/repository/exhibit/branches/2.0/src/webapp/api/scripts/exporters/exhibit-json-exporter.js

Scary reading. ;-) The 2.0 branch now outputs correct JSON, even for
data with ":s in them, though.

I'm considering making some light in-page API for returning that
structure as proper javascript objects of the same characteristics, so
same-page applications wouldn't be tempted to use that API and call
eval("("+json+")") to get at the structure. :-)

(But using the database API, one could probably work with the data
too, albeit with a slightly heavier java feel to it too. And I'm
mostly thinking aloud here; pardon the noise.)

> > I'm looking to do this so that I can send the JSON back to a server to
> > udpate some data items, so if anyone has an existing approach to this
> > more general problem (updating selected parts of Exhibit databases or,
> > even more generally, server-based JSON files), I'd love to hear them too.
>
> That's not really what Exhibit was designed for ... but let me know how
> that goes for you.

I'm also kind of interested. Making a JSON database (queryable by
restful URL, with JSONP output) in the cloud is another thing I'd be
interested in, but you are most likely shooting for a bit less than
that. It would probably make a very useful tool for you to achieve
your ends, though.

-- 
 / Johan Sundström, http://ecmanaut.blogspot.com/

_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general

Reply via email to