json_decode无法在php中运行
16lz
2021-01-22
Please check my below code and please let me know ehat wrong I am doing , I just want to decode the json and print on the browser as array
请检查我的下面的代码,请让我知道我正在做的错误,我只想解码json并在浏览器上打印为数组
<?php
$json = '{
"Token" : "xxx-xxx-xxx",
"ID": "1",
"Recipients": [
{
"Recipient_ID": "XX",
"From_Name": "XXX",
"From_Email": "XXX",
"To_Name": "XXX",
"To_Email": "XXX",
"Subject": "XXX",
"Message": "XXX",
"Attachments": [
{
"File_Name": "XXX",
"File_Path": "XXX",
}
],
}
],
}';
$input = $json;
print_r(json_decode(stripslashes($input)));
?>
I tried this json string to decode online (http://jsonviewer.stack.hu/) and its working fine so no issue with json string. Any help would be appreciate.
我尝试了这个json字符串在线解码(http://jsonviewer.stack.hu/),它的工作正常,所以json字符串没有问题。任何帮助将是欣赏。
2 个解决方案
#1
2
<?php
$json = '{
"Token": "xxx-xxx-xxx",
"ID": "1",
"Recipients": [{
"Recipient_ID": "XX",
"From_Name": "XXX",
"From_Email": "XXX",
"To_Name": "XXX",
"To_Email": "XXX",
"Subject": "XXX",
"Message": "XXX",
"Attachments": [{
"File_Name": "XXX",
"File_Path": "XXX"
}]
}]
}';
$input = $json;
var_dump(json_decode(stripslashes($input)));
?>
更多相关文章
- 更改数组键而不更改顺序
- 如何在数组中存储产品数量
- 使用PHP捕获正则表达式的字符串的一部分?
- php吧字符串直接转换成数组处理
- 使用 PHP usort() 通过用户自定义的比较函数对数组进行排序
- PHP print_r 转换/还原为数组
- 本机PHP函数将授予我直接访问字符串部分而无需创建临时数组的权
- 快速使用数组的最近元素来确定新元素是否唯一
- 填充PHP数组:首先检查索引?