1// Package attributevalue provides marshaling and unmarshaling utilities to
2// convert between Go types and Amazon DynamoDB AttributeValues.
3//
4// These utilities allow you to marshal slices, maps, structs, and scalar
5// values to and from AttributeValue type. These utilities make it
6// easier to convert between AttributeValue and Go types when working with
7// DynamoDB resources.
8//
9// This package only converts between Go types and DynamoDB AttributeValue. See
10// the feature/dynamodbstreams/attributevalue package for converting to
11// DynamoDBStreams AttributeValue types.
12//
13// Converting AttributeValue between DynamoDB and DynamoDBStreams
14//
15// The FromDynamoStreamsDBMap, FromDynamoStreamsDBList, and FromDynamoDBStreams
16// functions provide the conversion utilities to convert a DynamoDBStreams
17// AttributeValue type to a DynamoDB AttributeValue type. Use these utilities
18// when you need to convert the AttributeValue type between the two APIs.
19//
20// AttributeValue Marshaling
21//
22// To marshal a Go type to an AttributeValue you can use the Marshal,
23// MarshalList, and MarshalMap functions. The List and Map functions are
24// specialized versions of the Marshal for serializing slices and maps of
25// Attributevalues.
26//
27// The following example uses MarshalMap to convert a Go struct, Record to a
28// AttributeValue. The AttributeValue value is then used as input to the
29// PutItem operation call.
30//
31//     type Record struct {
32//         ID     string
33//         URLs   []string
34//     }
35//
36//     //...
37//
38//     r := Record{
39//         ID:   "ABC123",
40//         URLs: []string{
41//             "https://example.com/first/link",
42//             "https://example.com/second/url",
43//         },
44//     }
45//     av, err := attributevalue.MarshalMap(r)
46//     if err != nil {
47//         return fmt.Errorf("failed to marshal Record, %w", err)
48//     }
49//
50//     _, err = client.PutItem(context.TODO(), &dynamodb.PutItemInput{
51//         TableName: aws.String(myTableName),
52//         Item:      av,
53//     })
54//     if err != nil {
55//         return fmt.Errorf("failed to put Record, %w", err)
56//     }
57//
58// AttributeValue Unmarshaling
59//
60// To unmarshal an AttributeValue to a Go type you can use the Unmarshal,
61// UnmarshalList, UnmarshalMap, and UnmarshalListOfMaps functions. The List and
62// Map functions are specialized versions of the Unmarshal function for
63// unmarshal slices and maps of Attributevalues.
64//
65// The following example will unmarshal Items result from the DynamoDB's
66// Scan API operation. The Items returned will be unmarshaled into the slice of
67// the Records struct.
68//
69//     type Record struct {
70//         ID     string
71//         URLs   []string
72//     }
73//
74//     //...
75//
76//     result, err := client.Scan(context.Context(), &dynamodb.ScanInput{
77//         TableName: aws.String(myTableName),
78//     })
79//     if err != nil {
80//         return fmt.Errorf("failed to scan  table, %w", err)
81//     }
82//
83//     var records []Record
84//     err := attributevalue.UnmarshalListOfMaps(results.Items, &records)
85//     if err != nil {
86//          return fmt.Errorf("failed to unmarshal Items, %w", err))
87//     }
88//
89// Struct tags
90//
91// The AttributeValue Marshal and Unmarshal functions support the `dynamodbav`
92// struct tag by default. Additional tags can be enabled with the
93// EncoderOptions and DecoderOptions, TagKey option.
94//
95// See the Marshal and Unmarshal function for information on how struct tags
96// and fields are marshaled and unmarshaled.
97package attributevalue
98