user6633569
user6633569

Reputation:

Is it Possible to send JSON and store it in Azure Tables with JAVA

I was working on storing a data in azure tables in a meanwhile I found JSON support for Azure tables here. So for a change of plan now I have a data in JSON format i need it to store on azure tables.I found few code snippets but all were for c#. Can you please guide me ?

Thanks in Advance

Upvotes: 1

Views: 1437

Answers (2)

Peter Pan
Peter Pan

Reputation: 24138

@AnandDeshmukh, Based on my understanding, I think you might want to use Java to write the similar code with C#. I suggest that you can try to refer to the javadoc of Azure Storage SDK to rewrite the sample code in Java.

For example, you can use the Java code instead of the C# code as below.

C# code:

CloudTableClient tableClient = new CloudTableClient(baseUri, cred)
{
     // Values supported can be AtomPub, Json, JsonFullMetadata or JsonNoMetadata
     PayloadFormat = TablePayloadFormat.JsonNoMetadata
};

Java code:

CloudTableClient tableClient = new CloudTableClient(baseUri, cred)
tableClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata);

Upvotes: 1

Gaurav Mantri
Gaurav Mantri

Reputation: 136266

Azure Table Storage is a Key/Value pair store as opposed to a document store (a good example for that would be DocumentDB). Essentially a table contains entities (broadly think of them as rows) and each entity contains some attributes (broadly think of them as columns). Each attribute consist of 3 things: Attribute name (that would be the key in key/value pair), attribute value (that would the value in key/value pair) and attribute data type.

To answer your question, yes, you can store a JSON document in Azure Tables but that goes in as an attribute thus you need to assign a key to your JSON document. Furthermore each attribute can't be more than 64KB in size so you would need to take that into consideration.

If your requirement is to store JSON documents, I woul recommend looking into DocumentDB. It is more suitable for storing JSON data and doing many more things that Azure Tables can't do.

Regarding your comment about JSON support for Azure table, it talks about the format in which data is sent to/retrieved from Azure tables. In the earlier days, data was transmitted using ATOM PUB XML format which made the request payload/response body really bulky. With JSON format, the size is considerably reduced. However no matter which way you go, Azure Tables store the data in key/value pair format.

Upvotes: 2

Related Questions