Recently I got an appointment where I need to download some data from Cloud using it's REST API and store the values from that "string" in an object or in some variables. The download is done, all I need to do now is to parse somehow the data.
Until now i made this kind of code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("some link");
request.ContentType = "application/json; charset=utf-8";
request.Method = "GET";
request.Headers.Add("Carriots.apiKey", "key");
using (WebResponse response = request.GetResponse())
{
using(Stream stream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(stream);
JObject json = JObject.Parse(reader.ReadToEnd());
Console.WriteLine(json.ToString());
}
}
And here is the output:
{
"total_documents": 3,
"result": [
{
"_id": "...",
"protocol": "v1",
"checksum": "",
"_t": "str",
"at": 1444134377,
"device": "-just a device-",
"data": {
"field1": "123",
"field2": "1536"
},
"id_developer": "....",
"created_at": 1444134377,
"owner": "-someUser-"
}
]
}
I know that there are a lot of solutions on the internet, but none of them does what I need. Okay, I found something, but that iterates on every line and checks the values that way, but in my case I can have thousands of outputs like this.
Are there any ways to do all that (I mean the parsing) using some kind of built-in functions or the only solution is to iterate or write some regular expression?