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形式的字符

  • 相关阅读:
    CSP-S2019 退役记
    近期考试反思
    有关近期情况的总结与反思
    我好难啊
    AFO
    智障错误集锦
    关于博客密码【asd
    关于csp-s的各种问题整理
    CSP-S 临别赠言( 二 )
    分层图最短路 乱搞分享
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6198989.html
Copyright © 2011-2022 走看看