请帮我把这个Perl数组转换成PHP数组:
{
'method' => 'sip_endpoint.save',
'parameters' => {
'transport' => [
'UDP' <-------especially this one
],
'object_type' => 'sip_endpoint',
'nat' => 'yes'
}
}
答案 0 :(得分: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