It's all about the answers!

Ask a question

Parse Jazz REST API Output


Grace Gao (111) | asked Apr 21 '15, 6:50 p.m.
I have tried to use RTC RESTAPI for some administrative tasks. It's fairly simple to get xml output. However I have not found a working parser to push the output in JSON or an easy to use hash. I try to avoid parsing with regular expression. Any suggestions? Thanks.

Comments
Donald Nong commented Apr 21 '15, 7:25 p.m.

Can you make it more specific? Which API are you trying to use and what output do you expect? Some APIs can respond with JSON output if you put the "Accept: application/json" HTTP header in the request.


Grace Gao commented Apr 21 '15, 7:55 p.m.

Thanks for the quick response Donald. I use LWP::UserAgent. One example of get statement is like below:
$Response = $Browser->get( "$JazzURI" . "/process/project-areas")

One answer



permanent link
Donald Nong (14.5k414) | answered Apr 21 '15, 8:50 p.m.
This particular URI does return XML content only. I'm not quite sure why you cannot find a working parser in Perl as there are quite many to choose from. I'm not quite sure why you want to make it into JSON either. To do what you want, generally speaking, you need to parse the XML content in the stream (HTTP response), get a DOM tree, then serialize it into JSON format. You will need both XML and JSON modules to do so. I have no real experience on these Perl modules so can't make recommendations as such. The below links should get you started though.
https://developer.mozilla.org/en-US/docs/Web/Guide/Parsing_and_serializing_XML
https://developer.mozilla.org/en-US/docs/How_to_create_a_DOM_tree
http://www.perlmonks.org/?node_id=1075675
http://www.perlrdf.org/

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.