encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.

use JSON qw/encode_json decode_json/ ;
use Encode;
my $data = [
{
'name' => 'Ken' ,
'age' => 19
},
{
'name' => '测试' ,
'age' => 25
}
];
print encode_utf8("'name' => '测试'");
print "\n";
my $json_out = encode_json ( $data );
print $json_out;
print "\n"; encode_json $json_text = encode_json $perl_scalar
Converts the given Perl data structure to a UTF-8 encoded, binary string. This function call is functionally identical to: $json_text = JSON->new->utf8->encode($perl_scalar) encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
上一篇:Python 中 logging 日志模块在多进程环境下的使用


下一篇:BZOJ 1192 鬼谷子的钱袋 数论