从php中的URL获取json数据的问题

时间:2016-10-20 07:51:25

标签: php arrays json web-services

大家好我正在研究移动应用程序的Web服务,在我的情况下,来自移动设备的数据将以json格式接收问题是我无法解码json数据我只能得到它的post值

从移动设备发送的json数据

test:{"username":"abc1234","emailid":"abc@asd.com","password":"abc123","transactionpassword":"abc1234","phone":"1234567890","secretquestion":"What is the name of my pet?","secretanswer":"Tom"}

通过

获得以下数组
print_r($_POST);
    Array
    (
        [------WebKitFormBoundaryXb9aAj9gBd1dA41z
    Content-Disposition:_form-data;_name] => "test"

    {"username":"abc1234","emailid":"abc@asd.com","password":"abc123","transactionpassword":"abc1234","phone":"1234567890","secretquestion":"What is the name of my pet?","secretanswer":"Tom"}
    ------WebKitFormBoundaryXb9aAj9gBd1dA41z--

    )

当我试图解码时没有显示结果

print_r(json_decode($_POST));

帮我解码php中的json数据

1 个答案:

答案 0 :(得分:0)

看起来你应该首先获取实际的POST参数。

json_decode($_POST['test'])