-3
我想使用Gson庫解析下列數據。使用Gson庫解析Android JSON
{
"claimTypeList": [
"Dental",
"Outpatient",
"Hospitalisation/Surgery"
]
}
我想使用Gson庫解析下列數據。使用Gson庫解析Android JSON
{
"claimTypeList": [
"Dental",
"Outpatient",
"Hospitalisation/Surgery"
]
}
@Generated("org.jsonschema2pojo")
public class Example {
@SerializedName("claimTypeList")
@Expose
private List<String> claimTypeList = new ArrayList<String>();
/**
*
* @return
* The claimTypeList
*/
public List<String> getClaimTypeList() {
return claimTypeList;
}
/**
*
* @param claimTypeList
* The claimTypeList
*/
public void setClaimTypeList(List<String> claimTypeList) {
this.claimTypeList = claimTypeList;
}
}
創建一個模型類這樣
public class Claims {
List<String> claimTypes;
}
這裏將您的字符串爲對象
String data = "{\"claimTypeList\":[\"Dental\",\"Outpatient\",\"Hospitalisation/Surgery\"]}"
Claims c = new Claims();
c = new Gson().FromJson(data, Claims.class);
希望這有助於。