perl malformed JSON string, neither tag, array, object, number, string or atom, at character offset_malformed json string, neither array, object, numb

  1. [root@wx03 ~]# cat a17.pl
  2. use JSON qw/encode_json decode_json/ ;
  3. use Encode;
  4. my $data = [
  5. {
  6. 'name' => 'Ken' ,
  7. 'age' => 19
  8. },
  9. {
  10. 'name' => '测试' ,
  11. 'age' => 25
  12. }
  13. ];
  14. ##解json格式
  15. my $array = decode_json ( $data );
  16. print "1111111111\n";
  17. print $array->[0]->{name};;
  18. print "\n";
  19. print $array->[1]->{name};;
  20. print "\n";
  21. [root@wx03 ~]# perl a17.pl
  22. malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at a17.pl line 15.