我有一个情况。我是否可以通过gson知道如何从“地点”获取json,如下例所示?
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.type;
}
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;
}
}
我知道要在NEAR类中获取TYPE,它是
Gson json=new Gson();
near resultType =json.fromJson(result , near.class);
我可以知道如何在PLACE课程中获取NAME吗?感谢..
答案 0 :(得分:0)
怎么样:
resultType.getPlace().get(0).getname();