-1

TARGET: Store data to Cosmos DB without beautifying the json (remove white spaces)

PROBLEM: New Document is createed in CosmosDB with beautified, but it has white spaces in the content memory size of the document is almost 100kb. copied the content into a physical text file and removed the spaces so memory size only 50kb. My understanding from the azure cosmos db documentation price will calculate based on the storage of the documents and throughout is that correct ?

I tried like below by storing whole json into a object, Is there any other best possible way to decrease the size of the document.

[{
"users": "[{name: \"UserName1\"}, {name: \"UserName2\"}, {name: \"UserName3\"}]",
        "id": "93EC171E-XXXXXXX-9AEB9783EDD8",
        "_rid": "L5puALzZZQAwawMAAAAAAA==",
        "_self": "dbs/L5puAA==/colls/L5puALzZZQA=/docs/L5puALzZZQAwawMAAAAAAA==/",
        "_etag": "\"0f0046dc-0000-2900-0000-60a5781c0000\"",
        "_attachments": "attachments/",
        "_ts": 1621456924
    }
]

I would appreciate help and tips to make best possible way.

  • 1
    Does this answer your question? [Can keys in json document be compressed in Cosmos Db](https://stackoverflow.com/questions/59934018/can-keys-in-json-document-be-compressed-in-cosmos-db) – Thomas May 19 '21 at 21:54
  • No Thomas, Actually i am looking for remove the white spaces when storing into cosmosDb. updated question with the actual JSON which i tried to remove the white spaces. – Saidi Reddy May 19 '21 at 22:19
  • Yeah you're trying to minify the document but it s not possible atm – Thomas May 19 '21 at 22:33
  • Welcome! Can you please edit your question to show how you retrieved that JSON document you're showing? Cosmos DB doesn't *beautify* JSON when storing, but there are other things it stores, such as some system-level properties and index data. – David Makogon May 20 '21 at 11:16

1 Answers1

-1

For the moment it is not possible but the feature is being implemented:

Azure cosmos db - Compress stored data

See original SO post:

Can keys in json document be compressed in Cosmos Db

Thomas
  • 24,234
  • 6
  • 81
  • 125