【发布时间】:2013-02-16 18:35:44
【问题描述】:
我将这个发送给 PHP:
{'command' : 'move', 'data' : { 'seat_id' : '"+seat+"'}}
但无法通过 PHP 解析它。我从 PHP 得到的正确数据是:
{'command' : 'move', 'data' : { 'seat_id' : '44'}}
我尝试了以下方法:
<?php
$in = $Server->output(); //this is the json text
$o = json_decode($in); //has also tried put "TRUE" in the function.
print_r($o); ?>
它只是输出
{'command' : 'move', 'data' : { 'seat_id' : '44'}}
【问题讨论】:
-
正确的 JSON 使用双引号,而不是单引号。
-
哦,谢谢,哈哈。发布为答案。
-
你是如何创建那个字符串的?各种 JS 库会为你做 JSON 编码。
标签: php javascript json