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.
黄龙体育中心


 

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6200250.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值