i want to parse the following data using the Gson library.
{
"claimTypeList": [
"Dental",
"Outpatient",
"Hospitalisation/Surgery"
]
}
答案 0 :(得分:2)
@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;
}
}
答案 1 :(得分:2)
Create a model class like this
public class Claims {
List<String> claimTypes;
}
And here convert your string to object
String data = "{\"claimTypeList\":[\"Dental\",\"Outpatient\",\"Hospitalisation/Surgery\"]}"
Claims c = new Claims();
c = new Gson().FromJson(data, Claims.class);
hope this may help.