dounuo8797 2016-09-01 13:27
浏览 101
已采纳

json_decode无法在php中运行

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

<?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.

  • 写回答

2条回答 默认 最新

  • dsizmmwnm56437180 2016-09-01 13:33
    关注
    <?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)));
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能
  • ¥15 空间转录组CRAD遇到问题
  • ¥20 materialstudio计算氢键脚本问题