/// <summary> /// 从URL加载数据 /// </summary> /// <param name="url">访问地址</param> /// <returns></returns> public async Task <Project> LoadOneFromUrlAsync(string url) { MyJsonDataSource dataSource = new MyJsonDataSource(url); string projectJsonStr = await dataSource.LoadJsonStrFromWebAsync(); return(await DeserializeAsync(projectJsonStr)); }
public async Task <List <Employee> > LoadListFromUrlAsync(string url) { List <Employee> employees = new List <Employee>(); MyJsonDataSource dataSource = new MyJsonDataSource(url); string employeeStr = await dataSource.LoadJsonStrFromWebAsync(); JArray job = JArray.Parse(employeeStr); foreach (var employeeObject in job) { employees.Add(await DeserializeAsync(employeeObject.ToString())); } return(employees); }
/// <summary> /// 从URL加载一个集合 /// </summary> /// <param name="url">访问地址</param> /// <returns></returns> public async Task <List <Project> > LoadListFromUrlAsync(string url) { List <Project> projects = new List <Project>(); MyJsonDataSource dataSource = new MyJsonDataSource(url); string projectJsonStr = await dataSource.LoadJsonStrFromWebAsync(); JObject job = JObject.Parse(projectJsonStr); if (job.ContainsKey("content")) { foreach (JObject projectJsonObject in job["content"] as JArray) { projects.Add(await DeserializeAsync(projectJsonObject.ToString())); } } return(projects); }