{"ret":0,"LastModifiedTime":"2015-10-12 11:47:11","BookInfoList":[{"BookID":22,"BookCover":"98c6e147-51bb-4ab5-8fb1-d4d299197d44.jpg","BookName":"人教新课标五年级下册","BookVersionName":"新课标人教版","GradeName":"五年级","TermName":"下学期","BookCatalogList":[{"CatalogID":1568,"CataLogName":"第一组","ChildCatalogs":[{"CatalogID":1569,"CataLogName":"草原","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"CatalogID":1570,"CataLogName":"丝绸之路","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"CatalogID":1571,"CataLogName":"白杨","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"CatalogID":1572,"CataLogName":"把铁路修到拉萨去","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"CatalogID":1573,"CataLogName":"词语盘点","ChildCatalogs":[],"BookCourseList":[{"CourseID":36741,"CourseName":"课时1","Courserecord":0,"EndTime":"","StartTme":"","LevelName":null,"SubjectName":null,"BookVersionName":null,"GradeName":null,"TermName":null,"CataLogName":null,"BookResourceList":[],"CourseNoteList":[]}],"ParentCataLogID":1568},{"CatalogID":1574,"CataLogName":"口语交际·习作一","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"
怎么获取JSON里面的“BookInfoList”和“BookCatalogList”数组的值呢?请教各位大神,谢谢!
你都会得到ret的值了,后面的数组不会解析?
是的,因为“BookInfoList ”参数的参数类型是BookInfo ,我是在winform里面创建一个Model模型类,“BookInfoList ”里面的属性的类型应该写什么?
public int Ret { get; set; }
/// <summary>
/// 备课最新更新时间
/// </summary>
public string LastModifiedTime { get; set; }
/// <summary>
/// 教材信息
/// </summary>
public BookInfo BookInfoList { get; set; }
public int BookID { get; set; }
public string BookCover { get; set; }
public string BookName { get; set; }
public string BookVersionName { get; set; }
public string GradeName { get; set; }
public string TermName { get; set; }
/// <summary>
/// 教材目录(isbookcatalog为空或者false,BookCatalogList为null)
/// </summary>
public BookCatalog BookCatalogList { get; set; }
public int CatalogID { get; set; }
public string CataLogName { get; set; }
@梦随蝶舞: 你是前台返回到后台的json,前面2为都认为你是后台到前台的了,你直接可以用一个对象来转
public class A() { public int Ret{get;set;} public string Time{get;set;} public List<BookInfo> BookInfoList{get;set;} } public class BookInfo() { public int BookID{get;set;} ........... } 这样转
@梦随蝶舞:说明你解析出来了,这个问题自己先找下原因
什么叫“包含多个JSON”??
专业术语说错了,怎么把这些数据转换过来呢?我只会获取"ret":0,"LastModifiedTime":"2015-10-12 11:47:11",这两个参数的值
大神,怎么获取"BookInfoList"和"BookCatalogList"里面的内容呢?
@梦随蝶舞: json都有了,直接eval呗,说说你的场景吧。。。
@顾晓北: {"ret":0,"LastModifiedTime":"2015-10-12 11:47:11","BookInfoList":[{"BookID":22,"BookCover":"98c6e147-51bb-4ab5-8fb1-d4d299197d44.jpg","BookName":"人教新课标五年级下册","BookVersionName":"新课标人教版","GradeName":"五年级","TermName":"下学期","BookCatalogList":[{"CatalogID":1568,"CataLogName":"第一组","ChildCatalogs":[{"CatalogID":1569,"CataLogName":"草原","ChildCatalogs":[],"BookCourseList":[],"ParentCataLogID":1568},{"CatalogID":1570,"CataLogName":"丝绸之路","ChildCatalogs":[],"BookCourseList":[],
怎么获取"BookInfoList"里面的多个对象呢?我是在winform里面写的,创建了一个Model类,把需要返回参数封装了,然后另外一个类里面这样写的,可是数据获取不出来,麻烦帮我解决一下这个问题,谢谢!
public Model.GetDetailsResult GetDetails(string access_token, int userid, string tenant)
{
string url = string.Format(ServiceUrl.Lesson_GetDetails + "?access_token={0}&userid={1}&tenant={2}", access_token, userid, tenant);
HttpClient client = new HttpClient();
HttpResponseMessage getResponse = client.GetAsync(url).Result;
getResponse.EnsureSuccessStatusCode();
string result = getResponse.Content.ReadAsStringAsync().Result;
JavaScriptSerializer jss = new JavaScriptSerializer();
Model.GetDetailsResult gdr = jss.Deserialize<Model.GetDetailsResult>(result);
return gdr;
}
@梦随蝶舞: 你这不是代码都写出来了么?还需要什么?返回的数据已经反序列化出来了,你还需要什么东西?直接就可以访问啊。。。你的gdr数据结构是什么?
問題沒問完?
objectName.BookInfoList[0].BookID
物件屬性用點
Array內容用[]