Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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
为什么DynamoDB不会通过PHP api接受空映射?_Php_Amazon Dynamodb - Fatal编程技术网

为什么DynamoDB不会通过PHP api接受空映射?

为什么DynamoDB不会通过PHP api接受空映射?,php,amazon-dynamodb,Php,Amazon Dynamodb,我尝试使用Amazons PHP api将该项放到我的DynamoDB中,但是我得到了 Aws\DynamoDb\Exception\DYNAMODBEException[0]:找到列表的开头 没有预料到的地方 同样的json也可以通过Amazon web界面放置 Json: 由Aws\DynamoDb\Marshaler封送的PHP数组转储 array (size=2) 'Url' => array (size=1) 'S' => string 'test'

我尝试使用Amazons PHP api将该项放到我的DynamoDB中,但是我得到了

Aws\DynamoDb\Exception\DYNAMODBEException[0]:找到列表的开头 没有预料到的地方

同样的json也可以通过Amazon web界面放置

Json:

由Aws\DynamoDb\Marshaler封送的PHP数组转储

array (size=2)
  'Url' => 
   array (size=1)
     'S' => string 'test' (length=4)
  'Referers' => 
    array (size=1)
      'M' => 
        array (size=0)
          empty
我尝试使用空列表,但似乎只有空的贴图对象才会导致问题。为什么?仍然可以通过web界面实现这一点。有什么解决办法吗?或者我做错了什么

我的代码:

$client = DynamoDbClient::factory(/*settings*/);
$marshaler = new Marshaler();

$response = $client->putItem(array(
    'TableName' => 'StatisticsVisits', 
    'Item' => $marshaler->marshalJson('{"Url":"test","Referers":{}}')
));

空列表和空映射在PHP中是一样的。我们可以看到您输入数据并封送数据的代码吗?我可以提个建议。我加了代码,代码很短。当我将空映射{}更改为空列表[]时,它可以工作,但是这对我没有任何好处,因为我以后显然无法向它添加任何键/值对。感谢提供详细信息。让我们在这里继续讨论:
$client = DynamoDbClient::factory(/*settings*/);
$marshaler = new Marshaler();

$response = $client->putItem(array(
    'TableName' => 'StatisticsVisits', 
    'Item' => $marshaler->marshalJson('{"Url":"test","Referers":{}}')
));