I have a situation here. May I know how to get json from "place" like in the example below through gson?
near.java:
public class near{
private List<Place> place;
private String type;
public List<Place> getPlace(){
return this.place;
}
public void setPlace(List<Place> place){
this.place = place;
}
public String getType(){
return this.ty开发者_运维技巧pe;
}
public void setType(String type){
this.type = type;
}
}
place.java:
public class Place{
private String name;
public String getname(){
return this.name;
}
public void setname(String name){
this.name = name;
}
}
I know that to get TYPE in the NEAR class, it is
Gson json=new Gson();
near resultType =json.fromJson(result , near.class);
May I know how to get NAME in the PLACE class? Thanks..
How about:
resultType.getPlace().get(0).getname();
精彩评论