How to parse JSON array with gson in Android
                                        
                    •
                    Android                                    
                See English answers > how to parse JSON array with gson 7. I'm developing Android applications. I'm using gson to parse JSON responses. My JSON responses look like
[{"customerid":"abc","customername":"abc","location":null}
,{"customerid":"xyz","customername":"xyz","location":null}]
The class that parses this response looks like:
public class CustomerInfo 
{   
    @SerializedName("customerid")
    public String customerid;
    @SerializedName("customername")
    public String customername;
    @SerializedName("location")
    public String location;
    public CustomerInfo()
    {}
}
I tried it the following way:
  Gson gson = new Gson();
  List<CustomerInfo> customers = (List<CustomerInfo>)gson.fromJson(result,CustomerInfo.class);
But it doesn't suit me. What should I do? I need help. Thank you
resolvent:
Invalid Sign
Gson gson = new Gson();
JsonData gsonData = gson.fromJson(response, CustomerInfo.class);
for (int j = 0; j < gsonData.getCount(); j++) 
{
    String customerid = gsonData.get(j).getCustomerId();
    String customername = gsonData.get(j).getCustomerName();
    String location = gsonData.get(j).getLocation();
}
                
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        