我正在使用HttpClient從鏈接中獲取數據。將響應轉換爲可訪問的對象屬性
這裏是我的迴應:
#S7Z OK
#Mon Dec 26 02:26:58 EST 2016
image.anchor=168,186
image.embeddedIccProfile=0
image.embeddedPhotoshopPaths=0
image.embeddedXmpData=0
image.expiration=-1.0
image.height=373
image.iccProfile=sRGB IEC61966-2.1
image.mask=1
image.photoshopPathnames=
image.pixTyp=RGB
image.printRes=72
image.resolution=34
image.thumbRes=17
image.thumbType=2
image.timeStamp=1481737849826
image.width=336
我想這個響應訪問的對象轉換。
這裏是我的httpclient
工作:
using (var client = getHttpClient())
{
HttpResponseMessage response = await client.GetAsync(path);
if (response.IsSuccessStatusCode)
{
//var imageData = await response.Content.ReadAsAsync<imageData>();
//imageData.timeStamp
}
else
{
//TODO: Need to handle error scenario
}
}
我已經添加評論,讓你知道我想要做的。其實,我想從響應中獲得image.timeStamp
的值。
謝謝!
感謝您的回答。你能告訴我如何將這個響應數據轉換成Dictionary? – Saadi
這似乎是一個不錯的選擇。謝謝!但它在Dictionary中有一些錯誤的值。我使用正則表達式來修復它。 – Saadi