func unmarshalList()

in events/attributevalue.go [393:417]


func unmarshalList(target *DynamoDBAttributeValue, value interface{}) error {
	list, ok := value.([]interface{})
	if !ok {
		return errors.New("DynamoDBAttributeValue: L type should contain a list")
	}

	DynamoDBAttributeValues := make([]DynamoDBAttributeValue, len(list))
	for index, element := range list {

		elementMap, ok := element.(map[string]interface{})
		if !ok {
			return errors.New("DynamoDBAttributeValue: element of a list is not an DynamoDBAttributeValue")
		}

		var elementDynamoDBAttributeValue DynamoDBAttributeValue
		err := unmarshalDynamoDBAttributeValueMap(&elementDynamoDBAttributeValue, elementMap)
		if err != nil {
			return errors.New("DynamoDBAttributeValue: unmarshal of child DynamoDBAttributeValue failed")
		}
		DynamoDBAttributeValues[index] = elementDynamoDBAttributeValue
	}
	target.value = DynamoDBAttributeValues
	target.dataType = DataTypeList
	return nil
}