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 ?

In reply to XML2JSON Question by cliftonf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.