在使用json_decode()之后,为什么我没有在变量中获取数组,我感到有点困惑。我正在使用cURL发送一些帖子数据。以下是cURL
的帖子数据upload, post_data: Array
(
[local_file_path] => C:\videos\421F7D21-C659-43E1-9851-2397A4EEFB11.mp4
[botr_video] => "{\"path\":\"\\\/v1\\\/videos\\\/upload\",\"query\":{\"token\":\"b34f75e5c2c4a23db9850b147f0440fc536bcc7a21847e29\",\"key\":\"hKwNuueB\"},\"protocol\":\"http\",\"address\":\"upload.bitsontherun.com\"}"
)
所以我打电话给cURL,在cURL电话的接收方我有以下
$upload_link=json_decode($_POST['botr_video'], true);
$file_path=$_POST['local_file_path'];
$api_format="php";
error_log('upload link data is of type: '. gettype($upload_link));
当我查看我的错误日志时,它会写下:
upload link data is of type: string
不应该是一个数组吗?接收URL中的其余代码取决于json_decode的工作方式。我错过了什么吗?
此外,我在$upload_link
变量上应用json_decode函数之后记录了$_POST['botr_video']
变量,如下所示:
error_log('received upload link data: ' . print_r($upload_link, true));
以下是我在日志中的内容:
received upload link data: {"path":"\\/v1\\/videos\\/upload","query":{"token":"0835b9c46c0619cec9633a22bc9616a693696e4ea39a827c","key":"kRhvNuIF"},"protocol":"http","address":"upload.bitsontherun.com"}
为什么json_decode不接受发布数据并形成数组?似乎它将它留作一个字符串。