PutItem 的 AWS DynamoDB 问题。什么是正确的 JSON 格式?

AWS DynamoDB issue with PutItem. What's the proper JSON format?

我在将 PutItem 请求发送到 DynamoDB 时遇到问题。我知道有人回答了类似的问题 here,但我这里似乎没有空值。

我的JSON是:

{
    "TableName":"Unity",
    "Item":{
        "id":{
            "S":"73709359-ac78-46a0-8ca6-414393e33339"
        },
        "Session":{
            "S":"b6ba8b6d-ce27-4585-aee5-b9a2393e54da"
        },
        "Pos":{
            "X":{
                "S":"-16.8"
            },
            "Y":{
                "S":"-4.492812"
            }
        },
        "Time":{
            "S":"7/27/2017 3:21:25 PM"
        }
    }
}

错误是 ValidationException:

Supplied AttributeValue is empty, must contain exactly one of the supported datatypes

有人知道发生了什么事吗?

请尝试以下代码。我为属性 Pos.

添加了数据类型 Map
var dynamoDB = new AWS.DynamoDB;

var params = {
    TableName: "Unity",
    Item: {
        "id": {
            S: "73709359-ac78-46a0-8ca6-414393e33339"
        },
        "Session": {
            S: "b6ba8b6d-ce27-4585-aee5-b9a2393e54da"
        },
        "Pos": {
            M: {
                "X": {
                    S: "-16.8"
                },
                "Y": {
                    S: "-4.492812"
                }
            }
        },
        "Time": {
            S: "7/27/2017 3:21:25 PM"
        }
    }
};

console.log("Adding a new item...");
dynamoDB.putItem(params, function (err, data) {
    if (err) {
        console.error("Unable to add item. Error JSON:", JSON.stringify(err,
            null, 2));
    } else {
        console.log("Added item:", JSON.stringify(data, null, 2));
    }
});