程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> 服務器-Android這樣的JSON數據應該怎麼解析。

服務器-Android這樣的JSON數據應該怎麼解析。

編輯:編程解疑
Android這樣的JSON數據應該怎麼解析。

圖片說明

這是一個選擇添加疾病的頁面。
第一行是疾病類型
第二行是疾病名稱
要求上面的疾病類型和疾病名稱都要從服務器獲取。
每種疾病類型下面的疾病名稱數量不確定

還有可以點擊選擇添加日期,不過這個問題我已經解決了。
我采用的是ListView展示的。但是解析過後有問題,只能解析到疾病類型,解析不到疾病名稱。

每個疾病類型和疾病名稱都有ID。
這是用網頁訪問JSP網址的返回值。
{"code":200,"message":"調用成功","data":{"mem_message_records":[{"message_disease_typeid":"1","message_disease_type":"心血管系統"},{"message_disease_typeid":"2","message_disease_type":"外圍血管疾病"},{"message_disease_typeid":"3","message_disease_type":"腦血管疾病"},{"message_disease_typeid":"4","message_disease_type":"肺部疾病"},{"message_disease_typeid":"5","message_disease_type":"代謝疾病"},{"message_disease_typeid":"6","message_disease_type":"周圍神經疾病"},{"message_disease_typeid":"7","message_disease_type":"其他疾病"}],"mem_message_recordss":[[{"message_diseaseid":"1","message_disease":"冠狀動脈疾病"},{"message_diseaseid":"2","message_disease":"心絞痛"},{"message_diseaseid":"3","message_disease":"心肌梗死"},{"message_diseaseid":"4","message_disease":"冠狀動脈血運重建"},{"message_diseaseid":"5","message_disease":"充血性心力衰竭"}],[{"message_diseaseid":"6","message_disease":"閉塞性周圍動脈粥樣硬化"},{"message_diseaseid":"7","message_disease":"血栓行靜脈炎"}],[{"message_diseaseid":"8","message_disease":"腦血栓"},{"message_diseaseid":"9","message_disease":"短暫性腦供血不足"},{"message_diseaseid":"10","message_disease":"腦出血"}],[{"message_diseaseid":"11","message_disease":"慢性支氣管炎"},{"message_diseaseid":"12","message_disease":"慢性阻塞性肺病"},{"message_diseaseid":"13","message_disease":"支氣管哮喘"},{"message_diseaseid":"14","message_disease":"間質性肺病"},{"message_diseaseid":"15","message_disease":"囊性肺纖維化"}],[{"message_diseaseid":"16","message_disease":"1型糖尿病"},{"message_diseaseid":"17","message_disease":"2型糖尿病"},{"message_diseaseid":"18","message_disease":"糖尿病腎病"}],[{"message_diseaseid":"19","message_disease":"糖尿病性周圍精神病"},{"message_diseaseid":"20","message_disease":"自主神經性病變"}],[{"message_diseaseid":"21","message_disease":"高血壓"},{"message_diseaseid":"22","message_disease":"視網膜病變"},{"message_diseaseid":"23","message_disease":"惡性腫瘤"},{"message_diseaseid":"24","message_disease":"腦卒中"},{"message_diseaseid":"25","message_disease":"重性精神疾病"},{"message_diseaseid":"26","message_disease":"結核病"},{"message_diseaseid":"27","message_disease":"肝炎"},{"message_diseaseid":"28","message_disease":"先天畸形"},{"message_diseaseid":"29","message_disease":"其它"}]]}}

最佳回答:


寫一個類,結構和json格式對應,用gson直接轉為對象,對於不定數量的用List就行了

qq_33720124
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved