2016-04-25 108 views
0

這是我的json數組,其中有子數組。現在我想在android中以安排的方式存儲這個子數組的數據。就像先記錄另一個,等等..我該怎麼做?如何將我的JSON數組元素存儲在變量中?

{ 
    "result": [ 
     ["", "", "2016-04-22", "", "", "problems since last 5 days", "replace piping", "0", null], 
     ["Elec4820", "", "2016-04-25", "", "", "jsjshdjdjjcncnc", "hdjdhdhfbbff", "0", null], 
     ["Elec7558", "", "2016-04-25", "", "", "jsjshdjdjjcncnc", "hdjdhdhfbbff", "0", null], 
     ["Gara8118", "11827", "2016-03-13", "Completed", "nknm", "too much garbage near front gate causing an unbearable stink.", "garbage ", "0", null], 
     ["Nois6091", "17061", "2016-03-11", "Assigned", "Committee Member has been assigned to solve this problem", "too much noise caused by construction carried out by....ccd . .dvdv efv \r\nvvevv ", "cdhvdhb bbcsjc cincs nenvnjk \r\nvndjkn n cnicjisk m \r\niejnivn vvnveivnievnj invjievivn \r\nvienvncn", "1", null], 
     ["Wate6487", "14371", "2016-03-14", "In-Progress", "gyghbn", "fegrtb fbvrv ", "ss", "1", null] 
    ] 
} 
+0

你的json數組在哪裏?基本上你需要做的是爲內容創建一個模型類,然後使用Gson庫將其解析爲ListArray Nativ

回答

0

你的模型類必須是類似的東西:

public class Example { 

@SerializedName("result") 
@Expose 
private List<List<String>> result = new ArrayList<List<String>>(); 

/** 
* 
* @return 
* The result 
*/ 
public List<List<String>> getResult() { 
return result; 
} 

/** 
* 
* @param result 
* The result 
*/ 
public void setResult(List<List<String>> result) { 
this.result = result; 
} 

} 

後,讀GSON的文檔,要做到這一點:https://github.com/google/gson

0

,同時通過子陣列解析JSON循環,並添加哈希集是哪裏聲明模型