UPDATE: I am now sure that the problem is my retrofit call, it was retrieving the wrong data. I am testing the app with an android device, so localhost won't work. In my retrofit call, I've tried using my public ip and wifi ip (found using by seeing the properties of the wifi I'm connected to), yet the retrofit call is unable to get my JSON. Any ideas how to fix this?
For some reason, my JSON is considered as malformed by GSON, hence I used Gson.setLenient()
.
I checked my JSON with jslint
and it is valid. In addition, I'm unsure why the first line is considered to be a string
when it starts with {
.
Why is my JSON malformed and why is it throwing this error?
JSON
{
"result": [
{
"_id": "5924eea5bd50af38702c14ae",
"name": "Stoney's Bread Company",
"cuisineType": "Italian",
"address": "325 Kerr Street, Oakville",
"openTime": "0900",
"closeTime": "2100",
"lng": 43.443733,
"lat": -79.68146,
"__v": 0,
}
]
}
Retrofitcode
Gson gson = new GsonBuilder().setLenient().create();
final MapInterface retrofit = new Retrofit.Builder()
.baseUrl("http://myComputerIP/places/")
.addConverterFactory(GsonConverterFactory.create(gson))
.build().create(MapInterface.class);
Call<Result> call = retrofit.getMongoosePlace("3333733", "-79.681460");
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
public Integer getV() {
return v;
}
public void setV(Integer v) {
this.v = v;
}
}