cliftonf has asked for the wisdom of the Perl Monks concerning the following question:

Trying to use XML::XML2JSON to convert an XML response to JSON. I have it working but the application it is for seems to be picky and prefers JSON as created by the Google Chrome REST Console. I'm doing this:
$json = XML::XML2JSON->new(content_key => "Value",attribute_prefix => +"",pretty => 'true'); $jsondata = $json->convert($responsebody);
The JSON from XML::XML2JSON looks like this:
{ "Titles" : { "xmlns" : "urn:eventis:traxisweb:1.0", "resultCount" : "7", "Title" : [ { "Contents" : { "resultCount" : "1", "Content" : { "DurationInSeconds" : { "Value" : "11280" },
The JSON from the REST Console looks like this:
{ "Titles": { "resultCount": 7, "Title": [{ "Contents": { "resultCount": 1, "Content": [{ "DurationInSeconds": 11280,
Note the subtle differences in brackets and curly braces and spacing and the format of the duration value as well as the missing namespace value in the REST Console version. Is there a way I can make my perl script output JSON that matches the REST Console format ?

Replies are listed 'Best First'.
Re: XML2JSON Question
by tangent (Parson) on Mar 15, 2014 at 01:47 UTC
    Can you post the full JSON and wrap it in <code></code> tags (see Markup in the Monastery). Also it would help if you post the XML response too.