• 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
    ";
    use Data::Dumper;
    
    my $xx= Dumper($arr);        
    print $xx;
    print "
    ";
    print "111111111111111
    ";
    print $arr->[1]."
    "
    
    
    
    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.
    黄龙体育中心
    


    
                                        
    
  • 相关阅读:
    记录一次性能优化(转)
    Java线程池使用说明
    Spring AOP: Spring之面向方面编程
    hibernate 联合主键生成机制(组合主键XML配置方式)
    Hibernate配置文件hbm主键的generator可选项
    关于spring-mvc的InitBinder注解的参数
    Quartzs -- Quartz.properties 配置
    开源调度框架Quartz最佳实践
    Windows系统上如何使用SSH
    导入DEM数据到ArcGIS
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350906.html
Copyright © 2020-2023  润新知