-- 作者:fntfgz
-- 发布时间:2020/10/17 16:26:00
-- json多层嵌套循环解析
老师我获取了如下json代码,问题如下
1、老师看结构图,这片代码有5层,我第5层的professionName为一个记录行,前面层级的都信息也都需要整理下来,最后的数据行样式应该是这种格式 第一层
第二层
第三层
第四层
第五层 非定向
文史 本科提前批A段 kcm6s7s5|【阳】|cnpnr684|lcgr67p4|【院】| sb8qmdte|scn6pjeb|cjr6gn99|cmsoo6ae| 我看老师的例子没有找到这种多层循环嵌套的例子,我防写了几种也都报错,求老师给个代码
2、在我下面的这段json代码中collegeName是在第3层,但是真实的情况是有的是第3层,有的在第4层,并不是很规范,请问这种情况怎么判断
此主题相关图片如下:2020-10-17_160921.jpg
{ "result": { "totalCount": 5858, "items": [ { "type": "非定向", "remark": "", "level": 1, "colleges": [], "subset": [ { "type": "文史", "remark": "", "level": 2, "colleges": [], "subset": [ { "type": "本科提前批A段", "remark": "", "level": 3, "colleges": [ { "admissCode": "mkmc3a|cqps3a|ckhh3b|hck3rc|", "collegeId": 2111, "collegeName": "kcm6s7s5|【阳】|cnpnr684|lcgr67p4|【院】|", "planNum": "ojck30|", "remarks": "", "majors": [ { "majorCode": "", "professionName": "sb8qmdte|scn6pjeb|cjr6gn99|cmsoo6ae|", "professionCode": "ocr3ja|olcp30|", "professionDesc": "【(】|ckj6jgb4|mncpq6e5|【招】|mojrb8de|【。】|【只】|【招】|【男】|orc6ogc7|【。】|ooc6tt9c|【考】|【该】|【专】|imicg624|【须】|【提】|【前】|mjrc6rdf|【过】|tcqh6bm4|tkc6eiq5|【专】|cthio624|bt7oq3ka|【构】|【的】|nocgl637|【检】|【、】|【背】|cgjik6ac|【调】|lkcgh6b2|【、】|oqch69p2|ct6kijc6|chhl66g6|tcm6pfo9|ljbgdj4b|cjjmt6f6|jljoc664|【格】|【。】|lcpt6ak6|jcog65tc|【和】|【单】|rscjg6d1|cj69ilm6|【绩】|【要】|【求】|【详】|【询】|【院】|【校】|【,】|【择】|【优】|nhcnn68c|【取】|【。】|mrrc68tc|【取】|【不】|【认】|【可】|kic6hsa3|【策】|gcph6q57|nsckt64f|【)】|", "chooseSubject": "", "planNum": "ohqc30|", "cost": "ncms34|nqtc3a|cil3ka|ktqc3a|", "learnYear": "ttcs31|", "professionCodeReg": true, "costReg": true } ], "admissCodeReg": true, "admissCodes": "0036" }, "subset": [] } ] } ] } ] }, "code": "", "message": "", "fullMessage": "", "timestamp": "2020-10-17T07:35:45.3340884+08:00", "isSuccess": true }
|