in reply to array data to json
#!/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 | |
by snehit.ar (Beadle) on Jul 05, 2017 at 10:01 UTC | |
by choroba (Cardinal) on Jul 05, 2017 at 10:44 UTC | |
|
Re^2: array data to json
by snehit.ar (Beadle) on Jul 05, 2017 at 09:57 UTC | |
by choroba (Cardinal) on Jul 05, 2017 at 10:00 UTC | |
by snehit.ar (Beadle) on Jul 05, 2017 at 10:04 UTC | |
by choroba (Cardinal) on Jul 05, 2017 at 10:48 UTC |