Why should I convert DynamoDB JSON to Standard JSON format in Azure Cosmos DB?

Basically, this question arises in your little brain when you are curious to understand the differences between the two NoSQL databases out there in Azure and AWS or you are migrating from AWS Dynamo DB to Azure Cosmos DB NoSQL API or vice versa.

I will simplify this question in this blogpost.

AWS built the Dynamo DB and Azure built the Cosmos DB. They’re definitely different products and both companies are out there competing hard for the market.

AWS Dynamo DB was built using their own JSON standard DynamoDB JSON. The Dynamo DB JSON format allow you to specify the data types in the JSON structure.

Example of a Dynamo DB JSON reference:

{
  "CustomerId": {"S": "106"},
  "OrderDate": {"S": "2025-12-24T12:30:15.999Z"},
  "OrderNumber": {"N": "1004"},
  "IsActive": {"BOOL": false},
  "Tags": {"SS": ["books", "education"]},
  "Quantities": {"NS": ["1", "7"]},
  "BinaryData": {"B": "Qm9va0RhdGE="},
  "Attributes": {
    "M": {
      "Author": {"S": "John Doe"},
      "Pages": {"N": "350"}
    }
  },
  "RelatedItems": {
    "L": [
      {"S": "Notebook"},
      {"S": "Pen"}
    ]
  },
  "BinarySet": {
    "BS": [
      "Qm9va0RhdGE=",
      "Tm90ZWJvb2tEYXRh"
    ]
  },
  "DiscountCode": {"NULL": true}
}

The data types include as below,

Scalar Types (single values)

S – String, N – Number, B – Binary, BOOL – Boolean, NULL – Null

Document Types (nested)

M – Map, L – List

Set Types (collections of unique values)

SS – String Set, NS – Number Set, BS – Binary Set

Whereas Azure Cosmos DB follows a normal JSON structure such as string, number, Boolean and Null types.

For instance, after converting a Dynamo DB record into JSON record, the output appears as follows:

{
    "CustomerId": "106",
    "OrderDate": "2025-12-24T12:30:15.999Z",
    "DiscountCode": null,
    "OrderNumber": 1004,
    "BinaryData": "Qm9va0RhdGE=",
    "IsActive": false,
    "BinarySet": [
      "Qm9va0RhdGE=",
      "Tm90ZWJvb2tEYXRh"
    ],
    "Attributes": {
      "Pages": 350,
      "Author": "John Doe"
    },
    "Quantities": [
      1,
      7
    ],
    "RelatedItems": [
      "Notebook",
      "Pen"
    ],
    "Tags": [
      "education",
      "books"
    ]
  }


After conversion, the sequence of values in arrays or nested values are not guaranteed to remain the same as before migration.

Compatibility Issues:

Dynamo DB supports Sets (SS, NS, BS) and Binary types.

Cosmos DB does not natively support these data types and they must be converted to String or Arrays.

Risks

If the data is not converted into the correct standard JSON supported format, there is a loss of data and partitioning strategy cannot work properly in Cosmos DB.

Note: Always convert the DynamoDB JSON to standard JSON format which is supported by Cosmos NoSQL API. For more blogposts, visit Cloud Nerchuko

Disclaimer: This content is human-written and reflects hours of manual effort. The included code was AI-generated and then human-refined for accuracy and functionality.

Leave a Comment