I'm trying to parse this json:
[
{
"id": "1062",
"naam": "Test News Item",
"titel": "Test",
"datum": "31 mei 2016",
"author": "Adept",
"text": "TestTestTest",
"isNews": true,
"thumbnailFoto": "http://bunfunderi.com.tempwebsite.net/media/1005/cta.png",
"coverFoto": "http://bunfunderi.com.tempwebsite.net/media/1004/carpoolkey.jpg"
},
{
"id": "1078",
"naam": "Test News Item 2",
"titel": "Test News Item 2",
"datum": "28 mei 2016",
"author": "Adept",
"text": "Test News Item 2",
"isNews": true,
"thumbnailFoto": "http://bunfunderi.com.tempwebsite.net/media/1007/13116357_578696635638955_7776749753600994572_o.jpg",
"coverFoto": "http://bunfunderi.com.tempwebsite.net/media/1006/13012779_511873915682680_1813198322974994401_n.jpg"
},
{
"id": "1064",
"naam": "Tip 1",
"titel": "Tip 1",
"datum": "",
"author": "#4e8a43",
"text": "Tip 1Bla bla blaHet is zo ver bigi bigiDubai",
"thumbnailFoto": "http://bunfunderi.com.tempwebsite.net/media/1002/tipimage.png",
"coverFoto": "http://bunfunderi.com.tempwebsite.net/media/1009/tips_white.png",
"isNews": false
}
]
I'm using GSON to parse it to my "Home" object. While parsing it throws this error : Expected a string but was BEGIN_ARRAY at line 1 column 1876 path $[6].datum
This is my code
@Override
public void onResponse(Call call, Response response) throws IOException {
String data = response.body().string();
try {
JSONArray json = new JSONArray(data);
String object = json.toString();
List<Home> homeList = Arrays.asList(gson.fromJson(object,
Home[].class));
adapter.setList(homeList);
} catch (JSONException e) {
e.printStackTrace();
}
}
