ExitSerialization: JSON payload contracts in AWS1 / 9
Explanationassociate9 steps · 4 exercises

DynamoDB: who adds the type tags?

How to tell which layer encodes or decodes an AWS payload and what JSON structure and types must cross that boundary.

The DynamoDB low-level API requires a type descriptor on every attribute. For example, {"count":{"N":"42"}} sends a number, not a string attribute: the N tag gives the value its meaning. Numbers travel as strings tagged with N to preserve precision. Binary values travel as base64 text tagged with B; DynamoDB decodes that text back to binary.

With the JavaScript low-level client, your code supplies items in DynamoDB's tagged format. Use marshall() from @aws-sdk/util-dynamodb to convert a native JavaScript item to tagged attributes, and unmarshall() to convert tagged attributes back.

With the JavaScript document client, your code reads and writes standard JavaScript objects, such as { count: 42 }. The client handles the conversion for you. The wire contract does not change; what changes is which layer adds and removes the tags.

Next up: Sort the statements on what you just read.

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.