2017-02-03 8 views
0

JSONスキーマnullである:レトロフィット1.9応答

https://gyazo.com/654b65bc293518d8202573ddccfe1b61

私はresults arrayfirst objectをアクセスもしたいが、私はretrofit thorughそれを取得しようとしたとき、それはresults配列が空であることを述べています。何故ですか? (jsonschema2pojoから生成)

インタフェース

public interface MapInterface { 
@GET("/json") 
public void getResults(@Query("location") String location, @Query("radius") double radius, 
          @Query("type") String type, @Query("key") String key, Callback<Result> response); 

} 

MainActivity

RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("https://maps.googleapis.com/maps/api/place/nearbysearch/json?").build(); 
    MapInterface map = restAdapter.create(MapInterface.class); 

     map.getResults("65.9667,-18.5333", PROXIMITY_RADIUS, "restaurant", placesKey , new Callback<Result>() { 
     @Override 
     public void success(Result result, Response response) { 
      Log.d("Matt", result.getResults().toString()); 
      //this logs `D/Matt: []` 
     } 

     @Override 
     public void failure(RetrofitError error) { 
      Log.d("Matt", error.getMessage()); 
     } 
    }); 

POJO

+0

を試してみてください?それは非常に混乱しています。 –

答えて

0
public class Result { 
    @SerializedName("results") 
    @Expose 
    private List<Result> results = null; 
    @SerializedName("geometry") 
    @Expose 
    private Geometry geometry; 
    @SerializedName("icon") 
    @Expose 
    private String icon; 
    @SerializedName("id") 
    @Expose 
    private String id; 
    @SerializedName("name") 
    @Expose 
    private String name; 
    @SerializedName("opening_hours") 
    @Expose 
    private OpeningHours openingHours; 
    @SerializedName("photos") 
    @Expose 
    private List<Photo> photos = null; 
    @SerializedName("place_id") 
    @Expose 
    private String placeId; 
    @SerializedName("reference") 
    @Expose 
    private String reference; 
    @SerializedName("scope") 
    @Expose 
    private String scope; 
    @SerializedName("types") 
    @Expose 
    private List<String> types = null; 
    @SerializedName("vicinity") 
    @Expose 
    private String vicinity; 
    @SerializedName("rating") 
    @Expose 
    private Double rating; 

    public List<Result> getResults() { 
     return results; 
    } 

    public void setResults(List<Result> results) { 
     this.results = results; 
    } 

    public Geometry getGeometry() { 
     return geometry; 
    } 

    public void setGeometry(Geometry geometry) { 
     this.geometry = geometry; 
    } 

    public String getIcon() { 
     return icon; 
    } 

    public void setIcon(String icon) { 
     this.icon = icon; 
    } 

    public String getId() { 
     return id; 
    } 

    public void setId(String id) { 
     this.id = id; 
    } 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    public OpeningHours getOpeningHours() { 
     return openingHours; 
    } 

    public void setOpeningHours(OpeningHours openingHours) { 
     this.openingHours = openingHours; 
    } 

    public List<Photo> getPhotos() { 
     return photos; 
    } 

    public void setPhotos(List<Photo> photos) { 
     this.photos = photos; 
    } 

    public String getPlaceId() { 
     return placeId; 
    } 

    public void setPlaceId(String placeId) { 
     this.placeId = placeId; 
    } 

    public String getReference() { 
     return reference; 
    } 

    public void setReference(String reference) { 
     this.reference = reference; 
    } 

    public String getScope() { 
     return scope; 
    } 

    public void setScope(String scope) { 
     this.scope = scope; 
    } 

    public List<String> getTypes() { 
     return types; 
    } 

    public void setTypes(List<String> types) { 
     this.types = types; 
    } 

    public String getVicinity() { 
     return vicinity; 
    } 

    public void setVicinity(String vicinity) { 
     this.vicinity = vicinity; 
    } 

    public Double getRating() { 
     return rating; 
    } 

    public void setRating(Double rating) { 
     this.rating = rating; 
    } 

} 

Y OUは、GETメソッド

から返されるリターンJavaオブジェクトを追加する必要がありますなぜあなたはあなたのPOJOの検索結果を呼ぶのです。この

public interface MapInterface { 
@GET("/json") 
Call<Result> getResults(@Query("location") String location, @Query("radius") double radius, 
         @Query("type") String type, @Query("key") String key, Callback<Result> response); 

}