过去3天我一直在构建Shoutbox系统 它从JSON API输出运行
我试图将JSON的输出获取到Console.WriteLine中,但是每次加载应用程序时,都不会从API提取任何内容到应用程序。
printf
JSON API输出:
public class Shouts
{
public List<Shout> data { get; set; }
}
public class Shout
{
public string Username { get; set; }
public string Message { get; set; }
public string Time { get; set; }
}
//. . . extra code
static void Main(string[] args)
{
using (WebResponse wrs = getShout.GetResponse())
using (Stream stream = wrs.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
string json = reader.ReadLine();
while (!reader.EndOfStream)
{
while (!reader.EndOfStream)
{
Shouts data = JsonConvert.DeserializeObject<Shouts>(json);
foreach (var shout in data.Shouts)
{
Console.WriteLine($"Username: {shout.Username}");
}
}
}
Console.ReadKey();
}
}
我想在我的C#Shoutbox项目中列出“呼喊”