AWS-SDK-IOS 是否支持在 DynamoDB 中存储对象(可能是 Json 格式)?

Does AWS-SDK-IOS support for storing Objects in DynamoDB (May be in Json format)?

我需要在使用 Swift 开发的 IOS 移动应用程序中的 Dynamodb 中存储一些复杂的对象。到目前为止,我正在做的是使用第三方支持将现有对象转换为 Json 字符串,并将其作为字符串存储在 Dynamodb 列中。当我想读回它时,我从 DynamoDB 列中读取 json 字符串作为字符串,并将其转换回我想要的对象。

这是使用 AWS-SDK-Swift 时在 Dynamodb 中存储对象的最佳方式吗?是否有任何其他支持在 DynamoDB 中存储 json 字符串?

例如:-

class Mark
{
 var Subject :String?
 var Score :Int
}

class Student:AWSDynamoDBObjectModel ,AWSDynamoDBModeling
{

var Name :String?
var SID :Int
var Grade :Int
var Dob :String?
var Results :[Mark] =[]

......

}

是否可以将此对象直接保存到数据库中?里面有结果数组?

是的,DynamoDB 可以将 JSON 类对象存储到数据库中。

来自开发者指南:

Document Data Types:

DynamoDB supports List and Map data types, which can be nested to represent complex data structures.

A List type contains an ordered collection of values. A Map type contains an unordered collection of name-value pairs. Lists and maps are ideal for storing JSON documents. The List data type is similar to a JSON array, and the Map data type is similar to a JSON object. There are no restrictions on the data types that can be stored in List or Map elements, and the elements do not have to be of the same type.

The following example shows a Map that contains a String, a Number, and a nested List (which itself contains another Map).

[1]: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html

您可以使用 NSDictionary,如果我没记错的话,它会保存为地图。