Answer the question
In order to leave comments, you need to log in
How to use json array in C# received via WebRequests?
There is an array:
{"items":[{"key":1,"val":"one"},{"key":2,"val":"two"},{"key":3,"val":"three"},{"key":4,"val":"four"}]}
//data - десериализованный json массив
foreach(string value in data) {
print("ID: " + value.key + ", TEXT: " + value.val);
}
Answer the question
In order to leave comments, you need to log in
Something like this -
static void Main()
{
var afterWebRequests = "{\"items\":[{\"key\":1,\"val\":\"one\"},{\"key\":2,\"val\":\"two\"},{\"key\":3,\"val\":\"three\"},{\"key\":4,\"val\":\"four\"}]}";
var temp = (MyArray)JsonConvert.DeserializeObject(afterWebRequests, typeof(MyArray));
foreach(Item item in temp.items)
{
Console.WriteLine("Key: {0}, Value {1}", item.key, item.val);
}
Console.ReadKey();
}
public class MyArray
{
public List<Item> items { get; set; }
}
public class Item
{
public int key { get; set; }
public string val { get; set; }
}
stackoverflow.com/questions/17038810/newtonsoft-js... Actually, the name of the required library and an example of use for your task.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question