- Newest
- Most votes
- Most comments
The object format was chosen deliberately and there are solid technical reasons behind it. DynamoDB uses a typed attribute value format where each value is represented as an object with a single key indicating the data type, for example {"N": "1"} for a number or {"S": "hello"} for a string. This is known as the DynamoDB type descriptor format.
Here is why object over tuple makes sense: Self-documenting and unambiguous. {"N": "1"} tells you immediately that N is the type and "1" is the value without needing to know the positional convention. A tuple ["N", "1"] requires the consumer to always know that index 0 is the type and index 1 is the value, that is implicit knowledge that breaks across languages and teams. Extensible without breaking changes. Some DynamoDB types carry more complex values. For example a Map type {"M": {...}} or a List {"L": [...]} contain nested structures that would not fit cleanly into a two-element tuple. The object format handles simple and complex types consistently with the same pattern.
Language agnostic parsing. JSON objects with named keys are easier to deserialise reliably across Python, Java, Go, and JavaScript than positional tuples. Every JSON parser in every language handles key-value objects natively. For practical use, the AWS SDK handles this automatically. You rarely need to deal with the raw wire format directly because DocumentClient in JavaScript or boto3 in Python deserialises it into native types for you.
Reference: DynamoDB data types and attribute values: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
DynamoDB low-level API attribute value format: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html
Relevant content
- asked a year ago
- asked 4 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
