我必须处理具有很多嵌套的动态JSON密钥且嵌套很多的API。
我的Json响应是这样的:
{
"success": true,
"data": {
"infoArr": {
"868.111": {
"COURSE_ID": "868.111",
"COURSE_NAME_PL": "DRILLING EQUIPMENT DESIGN",
"COURSE_NAME_SL": "تصميم معدات حفر",
"COURSE_NAME": "DRILLING EQUIPMENT DESIGN",
"COURSE_CODE": "PE4206",
"COURSE_CREDITS": "3",
"REG_CREDITS_COUNT": "3",
"REQUIREMENT_TYPE_ID": "5",
"REQUIREMENT_ID": "26.111",
"REQUIREMENT_TYPE_PL": "Mandatory Degree Requirements",
"REQUIREMENT_TYPE_SL": "متطلبات الشهادة الإجبارية",
"REQUIREMENT_TYPE": "Mandatory Degree Requirements",
"CREDITS_COUNT": "162",
"REQUIREMENT_PASSED_CREDITS": "127",
"IS_REQUESTABLE": "Y",
"STATUS_REASON_PL": "Passed All Conditions",
"STATUS_REASON_SL": "يمكن تسجيل المقرر",
"STATUS_REASON": "Passed All Conditions",
"YEAR_ORDER": "4",
"SEMESTER_ORDER": "1",
"PASSED_PREREQUISITES": ",",
"LAST_REGISTER_SEMESTER_ID": "20171",
"REGISTER_STATUS": "R",
"FINISH_STATUS": "F",
"SUB_TOTAL": "26.5",
"FINAL_EXAM": "21",
"FINAL_MARK": "48",
"LAST_REGISTER_SEMESTER_PL": "First Semester 2017/2018",
"LAST_REGISTER_SEMESTER_SL": "الفصل الأول 2017/2018",
"SERIAL": 1
},
"871.111": {
"COURSE_ID": "871.111",
"COURSE_NAME_PL": "SECONDARY RECOVERY",
"COURSE_NAME_SL": "الاستخلاص المعزز",
"COURSE_NAME": "SECONDARY RECOVERY",
"COURSE_CODE": "PE4209",
"COURSE_CREDITS": "3",
"REG_CREDITS_COUNT": "3",
"REQUIREMENT_TYPE_ID": "5",
"REQUIREMENT_ID": "26.111",
"REQUIREMENT_TYPE_PL": "Mandatory Degree Requirements",
"REQUIREMENT_TYPE_SL": "متطلبات الشهادة الإجبارية",
"REQUIREMENT_TYPE": "Mandatory Degree Requirements",
"CREDITS_COUNT": "162",
"REQUIREMENT_PASSED_CREDITS": "127",
"IS_REQUESTABLE": "Y",
"STATUS_REASON_PL": "Passed All Conditions",
"STATUS_REASON_SL": "يمكن تسجيل المقرر",
"STATUS_REASON": "Passed All Conditions",
"YEAR_ORDER": "4",
"SEMESTER_ORDER": "2",
"PASSED_PREREQUISITES": ",",
"LAST_REGISTER_SEMESTER_ID": "20164",
"REGISTER_STATUS": "E",
"FINISH_STATUS": "F",
"SUB_TOTAL": "17",
"FINAL_EXAM": "12",
"FINAL_MARK": "29",
"LAST_REGISTER_SEMESTER_PL": "Complementary Period 2016/2017",
"LAST_REGISTER_SEMESTER_SL": "الدورة التكميلية 2016/2017",
"SERIAL": 1
}
},
"requestCourseArr": {
"868.111": {
"COURSE_ID": "868.111",
"COURSE_NAME_PL": "DRILLING EQUIPMENT DESIGN",
"COURSE_NAME_SL": "تصميم معدات حفر",
"COURSE_NAME": "DRILLING EQUIPMENT DESIGN",
"COURSE_CODE": "PE4206",
"COURSE_CREDITS": "3",
"REG_CREDITS_COUNT": "3",
"REQUIREMENT_TYPE_ID": "5",
"REQUIREMENT_ID": "26.111",
"REQUIREMENT_TYPE_PL": "Mandatory Degree Requirements",
"REQUIREMENT_TYPE_SL": "متطلبات الشهادة الإجبارية",
"REQUIREMENT_TYPE": "Mandatory Degree Requirements",
"CREDITS_COUNT": "162",
"REQUIREMENT_PASSED_CREDITS": "127",
"IS_REQUESTABLE": "Y",
"STATUS_REASON_PL": "Passed All Conditions",
"STATUS_REASON_SL": "يمكن تسجيل المقرر",
"STATUS_REASON": "Passed All Conditions",
"YEAR_ORDER": "4",
"SEMESTER_ORDER": "1",
"PASSED_PREREQUISITES": ",",json
"LAST_REGISTER_SEMESTER_ID": "20171",
"REGISTER_STATUS": "R",
"FINISH_STATUS": "F",
"SUB_TOTAL": "26.5",
"FINAL_EXAM": "21",
"FINAL_MARK": "48",
"LAST_REGISTER_SEMESTER_PL": "First Semester 2017/2018",
"LAST_REGISTER_SEMESTER_SL": "الفصل الأول 2017/2018",
"SERIAL": 1
},
"871.111": {
"COURSE_ID": "871.111",
"COURSE_NAME_PL": "SECONDARY RECOVERY",
"COURSE_NAME_SL": "الاستخلاص المعزز",
"COURSE_NAME": "SECONDARY RECOVERY",
"COURSE_CODE": "PE4209",
"COURSE_CREDITS": "3",
"REG_CREDITS_COUNT": "3",
"REQUIREMENT_TYPE_ID": "5",
"REQUIREMENT_ID": "26.111",
"REQUIREMENT_TYPE_PL": "Mandatory Degree Requirements",
"REQUIREMENT_TYPE_SL": "متطلبات الشهادة الإجبارية",
"REQUIREMENT_TYPE": "Mandatory Degree Requirements",
"CREDITS_COUNT": "162",
"REQUIREMENT_PASSED_CREDITS": "127",
"IS_REQUESTABLE": "Y",
"STATUS_REASON_PL": "Passed All Conditions",
"STATUS_REASON_SL": "يمكن تسجيل المقرر",
"STATUS_REASON": "Passed All Conditions",
"YEAR_ORDER": "4",
"SEMESTER_ORDER": "2",
"PASSED_PREREQUISITES": ",",
"LAST_REGISTER_SEMESTER_ID": "20164",
"REGISTER_STATUS": "E",
"FINISH_STATUS": "F",
"SUB_TOTAL": "17",
"FINAL_EXAM": "12",
"FINAL_MARK": "29",
"LAST_REGISTER_SEMESTER_PL": "Complementary Period 2016/2017",
"LAST_REGISTER_SEMESTER_SL": "الدورة التكميلية 2016/2017",
"SERIAL": 1
}
},
"groupCourseArr": {
"868.111": {
"T_GROUPS": {
"30669": "1 (0/40)",
"": ""
},
"P_GROUPS": {
"30670": "1 (0/20)",
"30671": "2 (0/20)",
"": ""
},
"T_GROUPS_OPTIONS": [],
"P_GROUPS_OPTIONS": []
},
"871.111": {
"T_GROUPS": {
"30672": "1 (0/40)",
"": ""
},
"P_GROUPS": {
"": ""
},
"T_GROUPS_OPTIONS": [],
"P_GROUPS_OPTIONS": []
}
}
}
}
我的问题是如何处理此数据类型,因为它没有const SerializedName才能使用Gson对其进行序列化并为该响应生成一个适当的POJO类。
我正在使用Retrofit来处理网络操作。
编辑:除了迭代一系列JsonObjects
和Maps of Entry
之外,我寻求一种更简便的方法来执行此操作,因为在API中存在更为复杂和嵌套的API请求服务器。