I know there's a few similar question but none of them match to my problem. I have JSON response from server that looks like this :
{
"data": {
"list": {
"beacons": [
{
"id": 56,
"beacon_id": "56",
"bridge_id": null,
"mesh_id": null,
"name": "Test beacon wcx",
"location": "test",
"mac_address": "e6:f5:8a:94:b8:c7",
"firmware": "1.1",
"pcb_revision": "2.0",
"battery_level": null,
"password": "0000",
"ib": {
"turn_on": "1",
"major": "300",
"minor": "10",
"tx_power": "4",
"interval": "400",
"uuid": "dae19960-18ea-11e5-8ff0-0002a5d5c521",
"secure_uuid": "0"
},
"euid": {
"turn_on": "0",
"namespace": null,
"instance": null,
"tx_power": null,
"interval": null
},
"eeid": {
"turn_on": "0",
"tx_power": null,
"interval": null
},
"eurl": {
"turn_on": "0",
"tx_power": null,
"interval": null,
"url": null
},
"etlm": {
"turn_on": "0",
"tx_power": null,
"interval": null
}
},
{
"id": 57,
"beacon_id": "57",
"bridge_id": "13",
"mesh_id": "278",
"name": "Marta B",
"location": "lk",
"mac_address": "e1:4b:64:c3:80:e2",
"firmware": "2.1",
"pcb_revision": "2.0",
"battery_level": "97",
"password": "0000",
"ib": {
"turn_on": "1",
"major": "300",
"minor": "6",
"tx_power": "0",
"interval": "0",
"uuid": "dae19960-18ea-11e5-8ff0-0002a5d5c521",
"secure_uuid": "0"
},
"euid": {
"turn_on": "0",
"namespace": null,
"instance": null,
"tx_power": null,
"interval": null
},
"eeid": {
"turn_on": "0",
"tx_power": null,
"interval": null
},
"eurl": {
"turn_on": "0",
"tx_power": null,
"interval": null,
"url": null
},
"etlm": {
"turn_on": "0",
"tx_power": null,
"interval": null
}
},
{
"id": 58,
"beacon_id": "58",
"bridge_id": null,
"mesh_id": null,
"name": "Marta C",
"location": "abcdlk",
"mac_address": "3c:cf:82:8a:e7:fe",
"firmware": "2.1",
"pcb_revision": "2.0",
"battery_level": "99",
"password": "0000",
"ib": {
"turn_on": "1",
"major": "300",
"minor": "39",
"tx_power": "7",
"interval": "400",
"uuid": "dae19960-18ea-11e5-8ff0-0002a5d5c521",
"secure_uuid": "0"
},
"euid": {
"turn_on": "0",
"namespace": null,
"instance": null,
"tx_power": null,
"interval": null
},
"eeid": {
"turn_on": "0",
"tx_power": null,
"interval": null
},
"eurl": {
"turn_on": "0",
"tx_power": null,
"interval": null,
"url": null
},
"etlm": {
"turn_on": "0",
"tx_power": null,
"interval": null
}
}
],
"bridges": [
{
"id": 13,
"name": "Test bridge wcx",
"location": "netizens",
"mac_address": "c9:1d:76:cc:a7:ca",
"ib": {
"turn_on": 1,
"major": "100",
"minor": "102",
"tx_power": "6",
"interval": "400",
"uuid": "dae19960-18ea-11e5-8ff0-0002a5d5c521",
"secure_uuid": 0
},
"euid": {
"turn_on": "0",
"namespace": null,
"instance": null,
"tx_power": null,
"interval": null
},
"eeid": {
"turn_on": "0",
"tx_power": null,
"interval": null
},
"eurl": {
"turn_on": "0",
"tx_power": null,
"interval": null,
"url": null
},
"etlm": {
"turn_on": "0",
"tx_power": null,
"interval": null
}
}
]
}
},
"ver": 1,
"time": 1475576646,
"status": 1,
"status_msg": ""
}
My model class looks like this :
public class BeaconResponse {
@Expose
public DataBeacon dataBeacon;
@Expose
public int ver;
@Expose
public long time;
@Expose
public int status;
@Expose
public String status_msg;
DataBeacon has list of Beacons and Bridges objects :
@Table(name = "dataBeacon", id = "_id")
public class DataBeacon extends Model {
@Column(name = "beacon",onUpdate = Column.ForeignKeyAction.CASCADE, onDelete = Column.ForeignKeyAction.CASCADE)
public List<BeaconsModel> beacons;
@Column(name = "bridge",onUpdate = Column.ForeignKeyAction.CASCADE, onDelete = Column.ForeignKeyAction.CASCADE)
public List<BridgeModel> bridges;
}
Here's my interface for getting json :
@GET("/api/mobile/{language}/{apiVersion}/beacons/list")
void beaconsList(Callback<BasicResponse<BeaconsListResponse>> callback);
public class BeaconsListResponse {
@Expose
public List<BeaconResponse> list;
}
Everything , in my opinion, should work correctly, but I'm still getting exception: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 18 path $.data.list. I don't know why - structure of the model should be correct .