I am writing an app to control Philips Hue smartlights using their REST API and Square's Retrofit library.
The problem is, when I make a call to /lights
the response comes back using each light's id
property as the key in the json response (rather than an array of light objects that is typical in a jsonapi response, and that seems to be expected by Retrofit).
Here is the request/response I'm looking at
GET /lights
returns
``` {
"1": {
"state": {
"on": true,
"bri": 144,
"hue": 13088,
"sat": 212,
"xy": [0.5128,0.4147],
"ct": 467,
"alert": "none",
"effect": "none",
"colormode": "xy",
"reachable": true
},
"type": "Extended color light",
"name": "Hue Lamp 1",
"modelid": "LCT001",
"swversion": "66009461",
"pointsymbol": {
"1": "none",
"2": "none",
"3": "none",
"4": "none",
"5": "none",
"6": "none",
"7": "none",
"8": "none"
}
},
"2": {
"state": {
"on": false,
"bri": 0,
"hue": 0,
"sat": 0,
"xy": [0,0],
"ct": 0,
"alert": "none",
"effect": "none",
"colormode": "hs",
"reachable": true
},
"type": "Extended color light",
"name": "Hue Lamp 2",
"modelid": "LCT001",
"swversion": "66009461",
"pointsymbol": {
"1": "none",
"2": "none",
"3": "none",
"4": "none",
"5": "none",
"6": "none",
"7": "none",
"8": "none"
}
}
} ```
Notice how instead of returning an array of light objects, it returns each light object keyed off its light id.
Anyone have an idea of how to parse this with Retrofit?