【问题标题】:Javascript, PHP json will not parse?Javascript、PHP json 不会解析?
【发布时间】: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


【解决方案1】:

正确的 JSON 使用双引号,而不是单引号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    相关资源
    最近更新 更多