Parse Jazz REST API Output
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.
|
One answer
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
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.
Comments
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.
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")