Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created October 28, 2012 23:55
Show Gist options
  • Save onevcat/3970516 to your computer and use it in GitHub Desktop.
Save onevcat/3970516 to your computer and use it in GitHub Desktop.
Perl_JSON
use JSON;
use Encode 'from_to';
# 假设$json是GBK编码的
my $json = '{"test" : "我是GBK编码的哦"}';
from_to($json, 'GBK', 'UTF-8');
my $data = decode_json($json);
use utf8;
use Encode;
my $array = decode_json($json_out);
use JSON qw/encode_json decode_json/;
my $data = [
{
'name' => 'Ken',
'age' => 19
},
{
'name' => 'Ken',
'age' => 25
}
];
my $json_out = encode_json($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment