zoukankan      html  css  js  c++  java
  • decode_json 必须是unicode形式的字符

    centos6.5:/root/test#cat a1.pl 
    use JSON qw/encode_json decode_json/;    
    use Encode;
    my $data = [    
        {  
            'name' => '科比',  
            'age' => 19  
        },  
        {  
            'name' => '乔丹',  
            'age' => 25  
        }  
    ];  
    my $json_out = encode_json($data);    
    print $json_out;  
    print "
    "; 
    centos6.5:/root/test#perl a1.pl 
    [{"name":"ç§æ¯","age":19},{"age":25,"name":"ä¹ä¸¹"}]
    
    
        $json_text = encode_json $perl_scalar
    Converts the given Perl data structure to a UTF-8 encoded, binary string.
    
    
    encode_json 转换给定的Perl 数据结构为一个UTF-8编码的 ,2进制字符串
    
      decode_json  
      
        $perl_scalar = decode_json $json_text  
    The opposite of encode_json: expects an UTF-8 (binary) string and tries to parse that as an UTF-8 encoded JSON text, returning the resulting referenc.
    
    
    和encode_json相反,期望一个UTF-8 2进制字符串和尝试解析一个UTF-8编码的JSON 文本,返回一个结果的参考
    
    decode_json 必须是unicode形式的字符,Dump不支持显示unicode形式的中文 只能 x{xxxx} 
    
    
    decode_json 必须是unicode形式的字符

  • 相关阅读:
    BZOJ 4525 二分
    BZOJ 4565 状压DP
    BZOJ 3930 容斥原理
    BZOJ 4562 搜索...
    BZOJ 4563 错排+高精度
    BZOJ 1833 数位DP
    BZOJ 4517 组合数+错排
    python 入门学习(二)
    python 入门学习
    Python 爬虫
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350035.html
Copyright © 2011-2022 走看看