For MarkMail we wrote and open sourced a library that outputs JSON: https://github.com/marklogic/commons/tree/master/json
It's different than the server built-in because this library assumes you want a particular flavor of JSON (the one Google expects) and so you construct some XML that follows certain rules and the output you get is that JSON. xqdoc comments are inline. -jh- On Jun 10, 2011, at 8:47 AM, Lee, David wrote: > Thanks ... reading more about what Google expects out of "JSON" (quoted > because it aint JSON) your right. > I will need to do some manual string processing, but it doesn't look that bad. > I may be able to use xdmp:to-json for some things ... > In any case I think I'm going to try this today on a small scale and see if > it actually works. > > > > > ---------------------------------------- > David A. Lee > Senior Principal Software Engineer > Epocrates, Inc. > [email protected] > 812-482-5224 > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Michael Blakeley > Sent: Friday, June 10, 2011 11:30 AM > To: General MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] Google Visualazation API in MarkLogic > > Sounds like an interesting project, David. I've done some chart work using > flot, but I'm afraid the code isn't public. It shouldn't be very difficult. > > One thing you may run into is that services expecting JSON tend to expect a > very specific JSON structure, and so the output from xdmp:to-json() may not > be appropriate. If that's the case, you may have to build your own JSON with > XQuery string-join() and concat() code. That isn't pretty, but it gets the > job done. > > -- Mike > > On 10 Jun 2011, at 08:11 , Lee, David wrote: > >> I'm experimenting with providing chart capability of a set of data. >> Stumbling over the various technologies (SVG, JavaScript charts, Flash >> charts , HTML5 etc.) I ran across Google Visualization. I've heard of this >> before but never dug into it. >> Google Visualization lets you define charts based on a dataset. The dataset >> can come from any server which supports its API's. >> http://code.google.com/apis/chart/interactive/docs/dev/implementing_data_source_overview.html >> >> The API's are fairly simple looking. There is pure Java code they supply as >> an example (and python) but I am thinking of writing something directly in >> MarkLogic App Server. The result has to be JSON (sigh) but it's not an >> overtly complicated JSON except some non-standard stuff like date >> constructors (yuck !). I was thinking I should be able to put together a >> query library that takes a result sequence and some metadata and produces >> the appropriate java using xdmp:to-json() mixed with some string processing. >> >> >> >> It seems intriguing and potentially very useful to be able to publish a >> MarkLogic dataset as a Google DataTable service. >> ( of course how to map arbitrary XML to the row/column nature of a table >> will have to be user-implemented, >> but the framework should be able to be done generically in XQuery). >> >> Has anyone done anything like this (I could borrow ?) >> Would anyone be interested in the results published if I get it to work ? >> >> >> ---------------------------------------- >> David A. Lee >> Senior Principal Software Engineer >> Epocrates, Inc. >> [email protected] >> 812-482-5224 >> >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
