khteh
khteh

Reputation: 3878

aws dynamodb import/export JSON format

I have exported JSON files from aws dynamodb in this format:

[
  {
    "__typename": "Article",
<snip>
  }
<snip>
]

This results in "Invalid JSON" error:

aws dynamodb batch-write-item --request-items file://Article.json

Error parsing parameter '--request-items': Invalid JSON:

The correct format is (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SampleData.LoadData.html) How to export the DynamoDB so that I could easily import it to tables? Or is there anything I could do to transform the JSON files that I receive from third party?

Upvotes: 0

Views: 1635

Answers (1)

Sri
Sri

Reputation: 402

The json seems to be invalid. you could use https://jsonlint.com/ to validate the JSON.

A sample valid JSON messages are available at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/samples/sampledata.zip

To import data to DynamoDB Table

aws dynamodb batch-write-item --request-items file://ProductCatalog.json
{
    "UnprocessedItems": {}
}

you could export data from DynamoDB using the following command

aws dynamodb scan --table-name ProductCatalog > ProductCatalog_export.json

DynamoDB can import data in three formats: CSV, DynamoDB JSON, and Amazon Ion.

  • CSV
  • DynamoDB Json
  • Amazon Ion

More information at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/S3DataImport.Format.html

Upvotes: 1

Related Questions