<?php $script_md51=array ( "tesdf.pl"=>"6775f86ba3d08541dcd9f72d95db7e36" , "tesdf2.pl"=>"2222" ); $enj=json_encode($script_md51); print "encode=".$enj."\n"; $end= json_decode($enj); var_dump($end); ?>结果:
#!/usr/bin/perl -w #author:jevons zeng #1.check pid of squid 2.check access.log of squid 3.check netstat 4.check store server use strict; use JSON; use Data::Dumper; my $jsonCoder = new JSON(); my $arr; $arr->{"tesdf.pl"}="6775f86ba3d08541dcd9f72d95db7e36"; $arr->{"tesdf2.pl"}="2222"; print Dumper($arr); my $enj= $jsonCoder->encode($arr); print "enj=".$enj,"\n"; my $j="{\"tesdf.pl\":\"6775f86ba3d08541dcd9f72d95db7e36\",\"tesdf2.pl\":\"2222\"}"; my $jd = $jsonCoder->decode($j); print Dumper($jd); print $jd->{"tesdf.pl"},"\n"; print $jd->{"tesdf2.pl"},"\n";
$VAR1 = {
'tesdf.pl' => '6775f86ba3d08541dcd9f72d95db7e36',
'tesdf2.pl' => '2222'
};
enj={"tesdf.pl":"6775f86ba3d08541dcd9f72d95db7e36","tesdf2.pl":"2222"}
$VAR1 = {
'tesdf.pl' => '6775f86ba3d08541dcd9f72d95db7e36',
'tesdf2.pl' => '2222'
};
6775f86ba3d08541dcd9f72d95db7e36
2222