I am developing an Android application and I am using gson to parse the json response. My json answer looks like
[{"customerid":"abc","customername":"abc","location":null} ,{"customerid":"xyz","customername":"xyz","location":null}]
And the class to parse this answer is as follows:
public class CustomerInfo { @SerializedName("customerid") public String customerid; @SerializedName("customername") public String customername; @SerializedName("location") public String location; public CustomerInfo() {} }
I tried this as follows:
Gson gson = new Gson(); List<CustomerInfo> customers = (List<CustomerInfo>)gson.fromJson(result,CustomerInfo.class);
But it does not work for me. How to do it. Need help. Thanks.
source share