You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
42 lines
1.4 KiB
|
3 years ago
|
using Newtonsoft.Json;
|
||
|
|
using Newtonsoft.Json.Linq;
|
||
|
|
using w230415_classes;
|
||
|
|
|
||
|
|
namespace w230415_consoleapi
|
||
|
|
{
|
||
|
|
internal class Program
|
||
|
|
{
|
||
|
|
static void Main(string[] args)
|
||
|
|
{
|
||
|
|
h_Process();
|
||
|
|
}
|
||
|
|
|
||
|
|
private static void h_Process()
|
||
|
|
{
|
||
|
|
HttpClient client = new HttpClient();
|
||
|
|
var res = client.GetAsync("http://localhost:5095/v1/hall").Result;
|
||
|
|
if (res.StatusCode == System.Net.HttpStatusCode.OK)
|
||
|
|
{
|
||
|
|
string sJson = res.Content.ReadAsStringAsync().Result;
|
||
|
|
//// 1. self
|
||
|
|
List<HallPlace>? chList = JsonConvert.DeserializeObject<List<HallPlace>>(sJson);
|
||
|
|
foreach (HallPlace item in chList)
|
||
|
|
{
|
||
|
|
Console.WriteLine($"{item.SeatRow}/{item.SeatPosition}: {item.Uid}");
|
||
|
|
}
|
||
|
|
// 2. dynamic
|
||
|
|
//dynamic json = JsonConvert.DeserializeObject(sJson);
|
||
|
|
//foreach (dynamic item in json)
|
||
|
|
//{
|
||
|
|
// Console.WriteLine($"{item.seatRow}/{item.seatPosition}: {item.uid}");
|
||
|
|
//}
|
||
|
|
// 3. JToken
|
||
|
|
//JToken json = JsonConvert.DeserializeObject<JToken>(sJson);
|
||
|
|
//foreach (JToken item in json)
|
||
|
|
//{
|
||
|
|
// Console.WriteLine($"{item["seatRow"]}/{item["seatPosition"]}: {item["uid"]}");
|
||
|
|
//}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|