Jason, I tried it and it works for me.
Thanks, Helen On Apr 20, 2010, at 7:57 PM, Jason Hunter wrote: > For people who want to produce *a specific JSON* and are willing to craft an > XML document as appropriate to accomplish that, there's a library in commons > that I wrote for our use in MarkMail: > > http://developer.marklogic.com/svn/commons/trunk/json/ > > Or actually here's its new and proper home on github: > > http://github.com/marklogic/commons/tree/master/json/ > http://github.com/marklogic/commons/raw/master/json/json.xqy > > The documentation is in xqdoc format within the file. The idea is you decide > what JSON you want to produce, then you create an XML document following the > simple rules of the library, and the library does the serialization from XML > to JSON for you. > > MarkMail uses this for Ajax-based updating of page contents. Click on a > facet, see the results update. The client can get the updated data in XML or > JSON format. > > http://markmail.org/results.xqy?q=json&mode=xml > http://markmail.org/results.xqy?q=json&mode=json > > -jh- > > On Apr 20, 2010, at 9:40 AM, Lee, David wrote: > >> Great Question. (awaiting answer from the experts) >> One thing to consider is that there is *no standard mapping from XML to JSON* >> So whatever ML may or may not provide its unlikely to do what you think it >> should. >> >> Thats not to say that you cant convert specific XML to specific JSON but >> there is no generalized agreed on way to do it. >> >> Simple example (it gets WAY worse). >> convert >> <element attr="foo">bar</element> >> >> To JSON >> >> Pick a way >> Pick another. >> which is better ? which is "right" ? >> Now add >> >> <element attr="foo">bar<spam bold="true">bletch</spam>more text >> <empty/></element> >> >> Did the way you first pick work for this too ? >> >> >> >> >> From: [email protected] >> [mailto:[email protected]] On Behalf Of helen chen >> Sent: Tuesday, April 20, 2010 12:32 PM >> To: General Mark Logic Developer Discussion >> Subject: [MarkLogic Dev General] question about json in marklogic 4 >> >> Does marklogic 4 has API that can convert xml node to json format string? >> >> I tried xdmp:to-json() function, it seems that it only wrap the xml node >> with double quote, didn't convert the xml node to json format. >> >> like: >> let $a := <a><b>test</b></a> >> return xdmp:to-json($a) >> >> I got result "<a><b>test</b></a>" >> >> >> Did I miss anything? Or does that mean I have to convert the xml to a xquery >> map and then call the function? >> >> Helen >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
