[root@wx03 ~]# cat a17.pl
use JSON qw/encode_json decode_json/ ;
use Encode;
my $data = [
{
'name' => 'Ken' ,
'age' => 19
},
{
'name' => '测试' ,
'age' => 25
}
];
##解json格式
my $array = decode_json ( $data );
print "1111111111
";
print $array->[0]->{name};;
print "
";
print $array->[1]->{name};;
print "
";
[root@wx03 ~]# perl a17.pl
malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at a17.pl line 15.