perl 解json数组

<pre name="code" class="cpp">http://11.36.10.82:4000/api/bus?bus=307&flag=1
返回json是:  其实就是数组的引用编码成json

["","黄龙体育中心","教工路花园亭","花园新村","浙江工商大学","保亭巷","教工路塘河路口","大关桥西","长乐路","二纺机总厂","沈塘湾","善贤社区","善贤坝","皋亭坝","李王桥","袁家村","张家园","杭玻","焦化分厂","沈家桥","毛竹山","薄板分厂","刘文村"]


jrhmpt01:/root# cat y1.pl 
use  LWP::UserAgent;
use Data::Dumper; 
use JSON qw/encode_json decode_json/;  
my $ua = LWP::UserAgent->new;
$phone=$ARGV[0];
$cc=$ARGV[1];
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("Mozilla/8.0");
$host = "http://115.236.160.82:3000/api/bus?bus=307&flag=1";
my $response = $ua->get($host);



  $ua->default_headers;
if ($response->is_success) {
 print $response->decoded_content;  # or whatever
my $json_out=$response->decoded_content; 
$arr = decode_json($json_out);
}
else {
 die $response->status_line;
};
print "11111111111111\n";
use Data::Dumper;

my $xx= Dumper($arr);        
print $xx;
print "\n";
print "111111111111111\n";
print $arr->[1]."\n"



jrhmpt01:/root# perl y1.pl 
["","黄龙体育中心","教工路花园亭","花园新村","浙江工商大学","保亭巷","教工路塘河路口","大关桥西","长乐路","二纺机总厂","沈塘湾","善贤社区","善贤坝","皋亭坝","李王桥","袁家村","张家园","杭玻","焦化分厂","沈家桥","毛竹山","薄板分厂","刘文村"]11111111111111
$VAR1 = [
          '',
          "\x{9ec4}\x{9f99}\x{4f53}\x{80b2}\x{4e2d}\x{5fc3}",
          "\x{6559}\x{5de5}\x{8def}\x{82b1}\x{56ed}\x{4ead}",
          "\x{82b1}\x{56ed}\x{65b0}\x{6751}",
          "\x{6d59}\x{6c5f}\x{5de5}\x{5546}\x{5927}\x{5b66}",
          "\x{4fdd}\x{4ead}\x{5df7}",
          "\x{6559}\x{5de5}\x{8def}\x{5858}\x{6cb3}\x{8def}\x{53e3}",
          "\x{5927}\x{5173}\x{6865}\x{897f}",
          "\x{957f}\x{4e50}\x{8def}",
          "\x{4e8c}\x{7eba}\x{673a}\x{603b}\x{5382}",
          "\x{6c88}\x{5858}\x{6e7e}",
          "\x{5584}\x{8d24}\x{793e}\x{533a}",
          "\x{5584}\x{8d24}\x{575d}",
          "\x{768b}\x{4ead}\x{575d}",
          "\x{674e}\x{738b}\x{6865}",
          "\x{8881}\x{5bb6}\x{6751}",
          "\x{5f20}\x{5bb6}\x{56ed}",
          "\x{676d}\x{73bb}",
          "\x{7126}\x{5316}\x{5206}\x{5382}",
          "\x{6c88}\x{5bb6}\x{6865}",
          "\x{6bdb}\x{7af9}\x{5c71}",
          "\x{8584}\x{677f}\x{5206}\x{5382}",
          "\x{5218}\x{6587}\x{6751}"
        ];

111111111111111
Wide character in print at y1.pl line 31.
黄龙体育中心



   

posted @ 2016-03-25 20:26  czcb  阅读(187)  评论(0编辑  收藏  举报