DynamoDB: Query JSON (Guide w/ Code Examples)

Provided by Rafal Wilinski
JavaScript AWS SDK does not provide a specific method to query data as JSON. But you can use the query operation to get data as an array and pass the result to JSON.stringify method to convert the array to a JSON string.
const AWS = require('aws-sdk'); const dynamoDb = new AWS.DynamoDB.DocumentClient(); const params = { TableName: 'tableName', KeyConditionExpression: 'primaryKey = :primaryKeyValue', ExpressionAttributeValues: { ':primaryKeyValue': 'value' } }; dynamoDb.query(params, (error, data) => { if (error) { console.error(error); return; } console.log(JSON.stringify(data.Items)); });
Similar Code Examples
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Query Count
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Delete Multiple Items in Javascript
- DynamoDB: BatchGetItem
- DynamoDB: Delete Table
- DynamoDB: Query Date Range
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Get Last Inserted Item
- DynamoDB: Like
- DynamoDB: Get Unique Values
- DynamoDB: Get By ID
- DynamoDB: Create if Not Exists
- DynamoDB: Get Last 10 Records
- DynamoDB: Attribute Not Null
Spend less time in the AWS console, use Dynobase.
First 7 days are. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase