Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
How do I get a full DynamoDB scan response from the aws-sdk-js-v3 without object types? (Marshaled response)

I'm answering this question for myself and others because I found the AWS JS SDK V3 documentation and examples to be super annoying and misleading. The official SDK docs do not provide an example for showing marshaled output so you see a bunch of object types in your response. The DDB Doc client by default will remove those but they don't show you how. The answer I am posting gives you a marshaled response, meaning it cleans out the object type strings.

An example of an unmarshalled response is like this, notice the S for string as the value type.

[
    {
      project_name: { S: 'fake project' },
      service_now_request_id: { S: 'CHG000212312' },
      service_now_request_url: {
        S: 'https://service-now.com/sampleApp?id=snx&spa=1&m=changes&r=0d12121aa442f33c8e0ebb3555'
      }
    }
]

If you want a response like below, you should use the full DDB document client:

[
    {
        project_name: 'fake project',
        service_now_request_id: 'CHG000212312',
        service_now_request_url: 'https://service-now.com/sampleApp?id=snx&spa=1&m=changes&r=0d12121aa442f33c8e0ebb3555',
    }
]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here's my sample code, feel free to nitpick or post a full ES6 version if you want.

const {DynamoDB} = require("@aws-sdk/client-dynamodb");
const { DynamoDBDocument } = require('@aws-sdk/lib-dynamodb');

const client = new DynamoDB({region: "us-west-2",});
const ddbDocClient = DynamoDBDocument.from(client);

async function marshaledScanOutput() {

    const primaryDynamoDBTableName = "yourDDBTableName";

    ddbParams = {TableName: primaryDynamoDBTableName};

    try {
        let testScan = await ddbDocClient.scan(ddbParams);
        let result = [];
    
        do {
            testScan.Items.forEach((item) => result.push(item));
            ddbParams.ExclusiveStartKey = testScan.LastEvaluatedKey;
        } while (typeof testScan.LastEvaluatedKey != "undefined");
    
        console.log(result);
        // Example output:
        // [
        //     {
        //       project_name: 'fake project',
        //       service_now_request_id: 'CHG000212312',
        //       service_now_request_url: 'https://service-now.com/sampleApp?id=snx&spa=1&m=changes&r=0d12121aa442f33c8e0ebb3555',
        //     }
        // ]
    }
    catch(error) {
        throw error;
    }
}

marshaledScanOutput();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!