我想将附件发布到TFS。因此,我需要形成如下所示的JSON(Sample Request body data from MSDN site)。
{“ 0”:137,“ 1”:80,“ 2”:78,“ 3”:71,“ 4”:13,“ 5”:10,
“ 6”:26,“ BYTES_PER_ELEMENT”:1,“ buffer”:{ “ 0”:137, “ 1”:80, “ 2”:78, “ 3”:71, “ 4”:13 “ 5”:10, “ 6”:26, “ byteLength”:8 },“ length”:6“ byteOffset”:0,“ byteLength”:6}
partial void PrepareRequest(HttpClient client, HttpRequestMessage request, StringBuilder urlBuilder)
{
string strPath = @"C:\Users\naveen\Desktop\Bytetxt.txt";
byte[] byTextData = File.ReadAllBytes(strPath);
request.Content = new StringContent(JsonConvert.SerializeObject(byTextData), Encoding.UTF8, "application/json");
}
我尝试了一些操作,但是无法获取适当的JSON。
如何将字节数组转换为上述确切的JSON格式?