using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Web.Script.Serialization; using System.Windows.Forms;
namespaceWindowsFormsApp1 { publicpartialclassForm1 : Form { publicForm1() { InitializeComponent(); }
privatevoidButton1_Click(object sender, EventArgs e) { // 获取数据 var url = "https://jsonplaceholder.typicode.com/users"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); Stream stream = req.GetResponse().GetResponseStream(); StreamReader reader = new StreamReader(stream); String content = reader.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); List<User> list = jss.Deserialize<List<User>>(content);