[英]How to retrieve blob data from MySql table and return it as Json format?
[英]how to retrieve blob data from Azure blob in Json format?
我已經將 json 數據格式存儲在 azure blob 存儲中,現在想以 json 的形式從 azure blob 中檢索該數據。
我試過如下
//get all blob from contrainer
var storageAccount = CloudStorageAccount.Parse("connection string");
var blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("tablesblob");
foreach (IListBlobItem item in container.ListBlobs(null, false))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
var ms = new MemoryStream();
//blob.DownloadToStream(ms); how to get blob data in the form of JSON?
}
}
如何以JSON的形式獲取天藍色的blob數據?
您可以嘗試CloudBlockBlob.DownloadText
方法將 blob 內容下載為文本,然后使用 Json.Net 的JsonConvert
將字符串序列化為您的客戶對象。 例如,類似於以下內容:
var customerData = blob.DownloadText();
var customer = JsonConvert.DeserializeObject<Customer>(customerData);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.