0

このPerl配列をPHP配列に変換するのを手伝ってください:

{
'method' => 'sip_endpoint.save',
'parameters' => {
     'transport' => [
                     'UDP'     <-------especially this one
                    ],
      'object_type' => 'sip_endpoint',
      'nat' => 'yes'
   }
}
4

1 に答える 1

1

単純な置換で..これは有効に変換できますjson

$json = "{
'method' => 'sip_endpoint.save',
'parameters' => {
     'transport' => [
                     'UDP' 
                    ],
      'object_type' => 'sip_endpoint',
      'nat' => 'yes'
   }
}";

$json = str_replace(array("'","=>"), array('"',":"), $json);
$array = json_decode($json,true);
print($array['parameters']['transport'][0]);  //what you want

出力

UDP
于 2013-03-19T23:38:15.860 に答える