我們正在使用來自HTTP Post請求的大型JSON流。目標是使用JsonTextReader將傳入的主體以JSON流式傳輸,並將嵌入式base64編碼的二進制文件提取到磁盤。在XML中,等效方法可能是 XMLReader.ReadElementContentAsBase64Async。將使用JsonTextReader值的Base64編碼字符串傳遞爲新流
使用JSON.NET,當我們迭代時,我們如何將encodedImages數組的每個項目發送到FileStream中,而無需在內存中保存整個字符串。
例JSON對象:
{
"company":"{clientCompany}",
"batchName":"{clientBatchName}",
"fileType":"{clientFileType}",
"encodedImages":[
"{base64encodedimage}",
"{base64encodedimage}",
"{base64encodedimage}"
],
"customFields":{
"{clientCustomField1}":"{clientCustomValue}",
"{clientCustomField2}":"{clientCustomValue}",
"{clientCustomField3}":"{clientCustomValue}",
"{clientCustomField4}":"{clientCustomValue}"
}
}
我不這麼認爲。 [這個問題](https://stackoverflow.com/q/46365304/3744182)從來沒有回答,這似乎導致問題#1462 [添加到JsonTextReader#1462二進制數據的緩衝讀取](https:// github .com/JamesNK/Newtonsoft.Json/issues/1462)被打開。 – dbc
@dbc看來這個問題是在1小時前提出的,問題在3周前被問到。也許我們的線程結合起來可以提高人們的認識:-) –
你總是可以給問題#1462添加一條評論,表明你也會喜歡這個能力。 – dbc