Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript、PHP和json不会解析吗?_Php_Javascript_Json - Fatal编程技术网

Javascript、PHP和json不会解析吗?

Javascript、PHP和json不会解析吗?,php,javascript,json,Php,Javascript,Json,我将此发送到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); /

我将此发送到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); ?>

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

正确的JSON使用双引号,而不是单引号。哦,谢谢,LOL。帖子作为答案。您是如何创建该字符串的?各种JS库将为您进行JSON编码。
 {'command' : 'move', 'data' : { 'seat_id' : '44'}}