Yep - that's one of the important properties of HDS - you can seamlessly pass it to anything that's expecting XML. So you can use the result from the DB query straight into an XSLT etc.
nk4um
How to convert HDS to other types e.g. JSON, XML
| Poster | Content |
|---|---|
|
nk4um Moderator
Posts: 763
|
|
|
nk4um User
Posts: 16
|
Any chance you can give an HDS to XML |
|
nk4um Moderator
Posts: 763
|
You beat me to it. But it was worth while looking into this since it looks like by coincidence there's a missing doc in json:core module for that accessor. Glad you worked it out - we'll post an update of the module to the repos with the correct doc for active:JSONFromHDS. |
|
nk4um User
Posts: 16
|
//from prev request hds = context.issueRequest(request) //convert to JSON request = context.createRequest("active:JSONFromHDS") request.addArgumentByValue("operand", hds) def jsonArray = context.issueRequest(request) context.createResponseFrom(jsonArray.toString()) |
|
nk4um User
Posts: 16
|
I am looking at the JSON core book (/book/view/book:json:core/) and would like to know how you use things like active:JSONFromHDS. Currently i am doing the following rather clunky code: //hds is a sql result hds = context.issueRequest(request) //process db request and turn it into json array def nodes = hds.getNodes("/resultset/row/*") def jsonArray = new JSONArray() def it = nodes.iterator() def jo = new JSONObject() while(it.hasNext()){ def node = it.next() jo.put(node.getName(),node.getValue()) } jsonArray.put(jo) Would be much nicer to be able to do that in one line. Thanks |