1// Package dynamodbattribute provides marshaling and unmarshaling utilities to
2// convert between Go types and dynamodb.AttributeValues.
3//
4// These utilities allow you to marshal slices, maps, structs, and scalar values
5// to and from dynamodb.AttributeValue. These are useful when marshaling
6// Go value tyes to dynamodb.AttributeValue for DynamoDB requests, or
7// unmarshaling the dynamodb.AttributeValue back into a Go value type.
8//
9// AttributeValue Marshaling
10//
11// To marshal a Go type to a dynamodbAttributeValue you can use the Marshal
12// functions in the dynamodbattribute package. There are specialized versions
13// of these functions for collections of Attributevalue, such as maps and lists.
14//
15// The following example uses MarshalMap to convert the Record Go type to a
16// dynamodb.AttributeValue type and use the value to make a PutItem API request.
17//
18//     type Record struct {
19//         ID     string
20//         URLs   []string
21//     }
22//
23//     //...
24//
25//     r := Record{
26//         ID:   "ABC123",
27//         URLs: []string{
28//             "https://example.com/first/link",
29//             "https://example.com/second/url",
30//         },
31//     }
32//     av, err := dynamodbattribute.MarshalMap(r)
33//     if err != nil {
34//         panic(fmt.Sprintf("failed to DynamoDB marshal Record, %v", err))
35//     }
36//
37//     _, err = svc.PutItem(&dynamodb.PutItemInput{
38//         TableName: aws.String(myTableName),
39//         Item:      av,
40//     })
41//     if err != nil {
42//         panic(fmt.Sprintf("failed to put Record to DynamoDB, %v", err))
43//     }
44//
45// AttributeValue Unmarshaling
46//
47// To unmarshal a dynamodb.AttributeValue to a Go type you can use the Unmarshal
48// functions in the dynamodbattribute package. There are specialized versions
49// of these functions for collections of Attributevalue, such as maps and lists.
50//
51// The following example will unmarshal the DynamoDB's Scan API operation. The
52// Items returned by the operation will be unmarshaled into the slice of Records
53// Go type.
54//
55//     type Record struct {
56//         ID     string
57//         URLs   []string
58//     }
59//
60//     //...
61//
62//     var records []Record
63//
64//     // Use the ScanPages method to perform the scan with pagination. Use
65//     // just Scan method to make the API call without pagination.
66//     err := svc.ScanPages(&dynamodb.ScanInput{
67//         TableName: aws.String(myTableName),
68//     }, func(page *dynamodb.ScanOutput, last bool) bool {
69//         recs := []Record{}
70//
71//         err := dynamodbattribute.UnmarshalListOfMaps(page.Items, &recs)
72//         if err != nil {
73//              panic(fmt.Sprintf("failed to unmarshal Dynamodb Scan Items, %v", err))
74//         }
75//
76//         records = append(records, recs...)
77//
78//         return true // keep paging
79//     })
80//
81// The ConvertTo, ConvertToList, ConvertToMap, ConvertFrom, ConvertFromMap
82// and ConvertFromList methods have been deprecated. The Marshal and Unmarshal
83// functions should be used instead. The ConvertTo|From marshallers do not
84// support BinarySet, NumberSet, nor StringSets, and will incorrectly marshal
85// binary data fields in structs as base64 strings.
86//
87// The Marshal and Unmarshal functions correct this behavior, and removes
88// the reliance on encoding.json. `json` struct tags are still supported. In
89// addition support for a new struct tag `dynamodbav` was added. Support for
90// the json.Marshaler and json.Unmarshaler interfaces have been removed and
91// replaced with have been replaced with dynamodbattribute.Marshaler and
92// dynamodbattribute.Unmarshaler interfaces.
93//
94// The Unmarshal functions are backwards compatible with data marshalled by
95// ConvertTo*, but the reverse is not true: objects marshalled using Marshal
96// are not necessarily usable by ConvertFrom*. This backward compatibility is
97// intended to assist with incremental upgrading of data following a switch
98// away from the Convert* family of functions.
99//
100// `time.Time` is marshaled as RFC3339 format.
101package dynamodbattribute
102