in reply to array data to json

The problem is that $remedyqueue doesn't contain an array (or better an array reference), but an XML::XPath::NodeSet object. You need to turn it to an array by using the get_nodelist method, but it returns a list of objects, so you need to convert them to something simpler - as you haven't shown the input XML, we can only guess, in my example, I used the string_value method:
#!/usr/bin/perl use warnings; use strict; use XML::XPath; use JSON; my $dom = 'XML::XPath'->new(xml => '<r><a>1</a><a>2</a><a>3</a></r>'); my $remedy_queue = $dom->find('/r/a'); print encode_json([ map $_->string_value, $remedy_queue->get_nodelist +]), "\n";

Output:

["1","2","3"]

BTW, if the newline comes last in the values, you can replace $var =~ s/\n//; by more common

chomp $var;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: array data to json
by Eily (Monsignor) on Jul 05, 2017 at 09:45 UTC

    ++. And chomp even works on a list, so all variables can be handled in one call : chomp($severity, $ticketnum, $timereceived, $service_name, $ssrid, $remedyqueue);

      if i use chomp instead of $severity =~ s/\n//; its goes in infinite loop to retrieve the data ..
        Please, try to read the whole sentences, not just blindly copy the code. I wrote

        > if the newline comes last in the values

        Clearly, newlines come first, so chomp is not applicable. But as you hadn't posted the XML before, I had to guess.

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^2: array data to json
by snehit.ar (Beadle) on Jul 05, 2017 at 09:57 UTC
    Sorry ,but i dont able to solve any of the problem with the give suggestions. let me know if any other information required.
      Let me repeat

      > as you haven't shown the input XML, we can only guess

      So, to be explicit, the input XML is required.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        Shared XML...Removed