У меня есть OneM2M API.который обеспечивает ответ JSON.в этом мне нужно хранить информацию одного дочернего узла в строковой переменной C #.Я получаю нулевое значение в переменной. Я хочу получить данные dataFrame кон-узла.
json data
{
"m2m:cin": {
"ty": 4,
"ri": "IoT/15a395/default/d37b4b81f9e",
"pi": "IoT/15a395/default",
"ct": "20180519T141254,000665",
"lt": "20180519T141254,000665",
"rn": "d37b4b81f9e",
"et": "20280516T141254,000664",
"st": 1,
"cr": "C7AACE9CB",
"cnf": "application/json",
"cs": 798,
"con": "{\"userid\":\"user1\",\"payloads_ul\":{\"id\":1526738533510,\"snr\":0,\"fcnt\":1166,\"freq\":865403015.1367188,\"live\":false,\"port\":2,\"rssi\":-99,\"deveui\":\"15a395\",\"cr_used\":\"4/5\",\"devaddr\":4262830997,\"dr_used\":\"SF12BW125\",\"sf_used\":12,\"gtw_info\":null,\"dataFrame\":\"QUxJVkUqQkFUMzUw\",\"decrypted\":true,\"timestamp\":\"2018-05-19T14:02:13.510Z\",\"time_on_air_ms\":1155.0720000000001,\"device_redundancy\":1}}"
}
}
code
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("url");
req.Method = "GET";
req.Headers["Authorization"] = "Basic " + "QzdBQUNFOUN";
req.ContentType = "application/vnd.onem2m-res+json";
req.Accept = "application/vnd.onem2m-res+json;";
req.Headers["Cache-Control"] = "no-cache";
req.Headers["X-M2M-RI"] = "9900001";
req.Headers["X-M2M-Origin"] = "C7AACE9-73";
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
var encoding = resp.CharacterSet == "" ? Encoding.UTF8 : Encoding.GetEncoding(resp.CharacterSet);
using (var stream = resp.GetResponseStream())
{
var reader = new StreamReader(stream, encoding);
var responseString = reader.ReadToEnd();
dynamic bin = Newtonsoft.Json.JsonConvert.DeserializeObject(responseString);
byte[] data = Convert.FromBase64String(bin.dataFrame.ToString());
}