func decodeGetItemOutput()

in dax/internal/client/response.go [335:376]


func decodeGetItemOutput(ctx context.Context, reader *cbor.Reader, input *dynamodb.GetItemInput, attrListIdToNames *lru.Lru, output *dynamodb.GetItemOutput) (*dynamodb.GetItemOutput, error) {
	if consumed, err := consumeNil(reader); err != nil {
		return output, err
	} else if consumed {
		return output, nil
	}

	projectionOrdinals, err := buildProjectionOrdinals(input.ProjectionExpression, input.ExpressionAttributeNames)
	if err != nil {
		return output, err
	}
	if output == nil {
		output = &dynamodb.GetItemOutput{}
	}
	err = consumeMap(reader, func(key int, reader *cbor.Reader) error {
		switch key {
		case responseParamConsumedCapacity:
			if output.ConsumedCapacity, err = decodeConsumedCapacity(reader); err != nil {
				return err
			}
		case responseParamItem:
			item, err := decodeNonKeyAttributes(ctx, reader, attrListIdToNames, projectionOrdinals)
			if err != nil {
				return err
			}
			if len(projectionOrdinals) == 0 {
				for k, v := range input.Key {
					item[k] = v
				}
			}
			output.Item = item
		default:
			return &smithy.SerializationError{Err: fmt.Errorf("unknown response param key %d", key)}
		}
		return nil
	})
	if err != nil {
		return output, err
	}

	return output, nil
}