Group
Extension

zhangbo-NLP-plugin_eng/lib/zhangbo/NLP/json.pl

#!/usr/bin/perl
use JSON::XS;
use Encode;
use Data::Dumper;
use strict;
use warnings;

my $content = "这是一段中文内容";

print "转码前的内部表示:\n";
print Dumper $content, "\n";
print "转码前的JSON:\n";
print JSON::XS->new->utf8->encode({
    content => $content
}), "\n";


# 对内容做一次转码就可以正常输出JSON了
$content = decode("utf-8", $content);
print "转码后的内部表示:\n";
print Dumper $content, "\n";
print "转码后的JSON:\n";
print JSON::XS->new->utf8->encode({
    content => $content
}), "\n";




Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.