Problem
Perl 实现 xml 转 json
Solution
#!/usr/bin/perl -w
use XML::Simple;
use Encode;
use JSON;
# use Data::Dumper;
# print Dumper (XML::Simple->new()->XMLin($ARGV[0]));
$xml = new XML::Simple;
my $data = $xml->XMLin($ARGV[0]);
# print "\$data\n";
my $a = $data->{"a"};
my $b = $data->{"b"};
my %hash = (
'a' => $a,
'b' => $b);
my $json_data = encode_json \%hash;
print "$json_data\n";