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:
>
> ---
>
> <link href="data.js" type="application/json" rel="exhibit/data" />
> ...
> <script>
>    window.database = Exhibit.Database.create();
>    window.database.loadDataLinks(
>      function() {
>        var json = window.database.getAsJSON();
>      }
>    );
> </script>
>
> ---
>
> ...and have the json variable be either the JavaScript object or JSON 
> string representation of the data.js file. (If it's a string, I clearly 
> don't care whether it preserves whitespace/indentation etc.)
>   
Try

    Exhibit.ExhibitJsonExporter.exportMany(database.getAllItems(), database)

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

If you're using Exhibit 2.0, then in the typical case "database" is a 
global variable. If not, then you need to call exhibit.getDatabase() and 
supposedly you already have a reference to "exhibit".

> 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.

David

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

Reply via email to