3 回答

TA貢獻1828條經驗 獲得超13個贊
我的快速修復可能是:
import boto3
import time
import sys
import json
client = boto3.client('quicksight')
def lambda_handler(event, context):
response = client.list_dashboard_versions(AwsAccountId='11111', DashboardId='2222',MaxResults=10)
return json.dumps(response, default=str)

TA貢獻1816條經驗 獲得超6個贊
返回看起來像這樣 -
{
? ? 'DashboardVersionSummaryList': [
? ? ? ? {
? ? ? ? ? ? 'Arn': 'string',
? ? ? ? ? ? 'CreatedTime': datetime(2015, 1, 1),
? ? ? ? ? ? 'VersionNumber': 123,
? ? ? ? ? ? 'Status': 'CREATION_IN_PROGRESS'|'CREATION_SUCCESSFUL'|'CREATION_FAILED'|'UPDATE_IN_PROGRESS'|'UPDATE_SUCCESSFUL'|'UPDATE_FAILED',
? ? ? ? ? ? 'SourceEntityArn': 'string',
? ? ? ? ? ? 'Description': 'string'
? ? ? ? },
? ? ],
? ? 'NextToken': 'string',
? ? 'Status': 123,
? ? 'RequestId': 'string'
}
如您所見,CreatedTime返回為日期時間。如果您想將其作為 JSON 返回,您應該轉換該值。

TA貢獻1794條經驗 獲得超7個贊
今天我正在努力解決這個問題,使用一種也返回日期時間的方法。
在我的示例中,'JoinedTimestamp': datetime(2015, 1, 1)導致相同的Unable to marshal response。
如果您不需要CreatedTime值,您也可以將其從響應中刪除,如下所示:
for account in list_accounts_response["Accounts"]:
if "JoinedTimestamp" in account:
del account["JoinedTimestamp"]
為了跟進 Joseph Lane 的答案,轉換這個值可能是這樣的:
for account in list_accounts_response["Accounts"]:
if "JoinedTimestamp" in account:
account["JoinedTimestamp"] = str(account["JoinedTimestamp"])
添加回答
舉報