2016-12-02 155 views

回答

1
@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; 
} 

} 

http://www.jsonschema2pojo.org/

2

創建一個模型類這樣

public class Claims { 
    List<String> claimTypes; 
} 

這裏將您的字符串爲對象

String data = "{\"claimTypeList\":[\"Dental\",\"Outpatient\",\"Hospitalisation/Surgery\"]}" 
Claims c = new Claims(); 
c = new Gson().FromJson(data, Claims.class); 

希望這有助於。