perl json encode_json decode_json

1178 단어
<pre name="code" class="cpp">Perl   decode_json()       Perl     JSON。        JSON       Perl     
use JSON qw/encode_json decode_json/;  
my $data = [  
    {
        'name' => 'Ken',
        'age' => 19
    },
    {
        'name' => 'xy',
        'age' => 25
    }
];
my $json_out = encode_json($data);  
print $json_out;
print "
"; my $array = decode_json($json_out); use Data::Dumper; my $xx= Dumper($array); print "111111111
"; print $xx; print "
"; print "222222222222222
"; print $array->[1]{name}; jrhmpt01:/root/wx# perl y1.pl [{"name":"Ken","age":19},{"name":"xy","age":25}] 111111111 $VAR1 = [ { 'name' => 'Ken', 'age' => 19 }, { 'name' => 'xy', 'age' => 25 } ]; 222222222222222 xy jrhmpt01:/root/wx# decode_json unicode ,Dump unicode \x{xxxx}

좋은 웹페이지 즐겨찾기