I am using a modification and analysis result using GSON. I donβt know why, but I get this
BEGIN_ARRAY expected, but BEGIN_OBJECT in row 1 of column 2 path
I know what this error means, but I see no reason.
This is my json answer
{"suggestions": [
{
"value": " ",
"unrestricted_value": " , ",
"data": {
"qc_complete": null,
"qc_house": null,
"qc_geo": "4",
"postal_code": "420000",
"postal_box": null,
"country": "",
"region_fias_id": null,
"region_kladr_id": null,
"region_with_type": " ",
"region_type": "",
"region_type_full": "",
"region": "",
"area_fias_id": null,
"area_kladr_id": null,
"area_with_type": null,
"area_type": null,
"area_type_full": null,
"area": null,
"city_fias_id": null,
"city_kladr_id": null,
"city_with_type": " ",
"city_type": "",
"city_type_full": "",
"city": "",
"city_district": null,
"settlement_fias_id": null,
"settlement_kladr_id": null,
"settlement_with_type": null,
"settlement_type": null,
"settlement_type_full": null,
"settlement": null,
"street_fias_id": null,
"street_kladr_id": null,
"street_with_type": null,
"street_type": null,
"street_type_full": null,
"street": null,
"house_fias_id": null,
"house_kladr_id": null,
"house_type": null,
"house_type_full": null,
"house": null,
"block_type": null,
"block_type_full": null,
"block": null,
"flat_area": null,
"square_meter_price": null,
"flat_price": null,
"flat_type": null,
"flat_type_full": null,
"flat": null,
"fias_id": "93b3df57-4c89-44df-ac42-96f05e9cd3b9",
"fias_level": "4",
"kladr_id": "1600000100000",
"tax_office": "1600",
"tax_office_legal": null,
"capital_marker": "2",
"okato": "92401000000",
"oktmo": "92701000",
"timezone": null,
"geo_lat": "55.7943051",
"geo_lon": "49.1116709",
"beltway_hit": null,
"beltway_distance": null,
"unparsed_parts": null,
"qc": null
}
} ]}
These are my models created by pojogenerator.
public class DadataResponse {
@SerializedName("suggestions")
@Expose
private List<Suggestion> suggestions = new ArrayList<Suggestion>();
public List<Suggestion> getSuggestions() {
return suggestions;
}
public void setSuggestions(List<Suggestion> suggestions) {
this.suggestions = suggestions;
}
}
public class Suggestion {
@SerializedName("value")
@Expose
private String value;
@SerializedName("unrestricted_value")
@Expose
private String unrestrictedValue;
@SerializedName("data")
@Expose
private Data data;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getUnrestrictedValue() {
return unrestrictedValue;
}
public void setUnrestrictedValue(String unrestrictedValue) {
this.unrestrictedValue = unrestrictedValue;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}
and a data class, but too large and you do not need to publish it here.
So why am I getting this error? Please, help
UPD
public ApiService(String URLSTRING){
RequestInterceptor requestInterceptor = new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
request.addHeader("Authorization", "Token");
request.addHeader("Content-Type","application/json");
request.addHeader("Accept","application/json");
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(URLSTRING)
.setRequestInterceptor(requestInterceptor)
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
mApi = restAdapter.create(Api.class);
}
public interface Api{
@GET("/address")
List<DadataResponse> getDadata(@Query("query") String query);
}