我有一个HTML5游戏,它将字符数据编码为JSON,然后使用POST将其发送到php文件。 这就是formdata的样子
{"onScreen":3,"quoteNum":4,"CHARACTER1":{"screenPos":1,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""},"CHARACTER2":{"screenPos":2,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""},"CHARACTER3":{"screenPos":3,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""}}:
唯一的问题是我不知道如何在php中检索编码的JSON。 当我只是尝试打印数据时,php只打印“数组”。
我如何简单地让php打印它发布的JSON数据?
答案 0 :(得分:0)
在将数据解码为数组之后,尝试在服务器端获取编码的json。
print '<pre>';
print_r(json_decode($_POST,1))
print '</pre>'
对于您的信息:您的json字符串末尾包含一个冒号:P