1 year ago
#379083
Element115
can't get correct value for item return from DynamoDB in swift
Trying to extract the value from DynamoDbClientTypes.AttributeValue into either json or a string value... but not working.The connection and return data is working but I am getting updateDate : s("04/05/2022 06:04:84") as the return data. How do I parse the s("04/05/2022 06:04:84") into something that I can use, I can't seem to convert it to a String or a json structure.. Everything I try it says it can't convert from DynamoDbClientTypes.AttributeValue
func getItemInTable(dynamoDbClient: DynamoDbClient, nameOfTable: String, key: String, keyVal: String) async throws {
let keyToGet = [key : DynamoDbClientTypes.AttributeValue.s(keyVal)]
do {
let results = try await dynamoDbClient.getItem(input: GetItemInput(key: keyToGet, tableName: nameOfTable))
guard let numbersMap = results.item else {
return
}
for returnedKey in numbersMap {
print("\(returnedKey.key) : \(returnedKey.value)")
}
} catch {
dump (error)
}
}
swift
amazon-web-services
amazon-dynamodb
dynamodb-queries
0 Answers
Your Answer