Hi,
I am scratching a bit my head over why parsing this JSON array doesn't work at all.
Source JSON:
[
{
"address": 63,
"connected": true,
"stateKnown": true,
"pairingEnabled": false,
"lifterShuttleLightBarrierBreached": false,
"warningSignalOn": false,
"emergencyStopTriggered": false,
"openDoors": {
"mainDoor": false,
"markedSecondaryDoors": [1,2,3,4]
},
"requestedAccess": {
"mainDoor": false,
"markedSecondaryDoors": []
},
"isTestModeActive": false,
"schematicId": "",
"notifictionsByType": {}
},
(...)
]
Specific code always returning nil. I am trying to get the variable array at "markedSecondaryDoors".
BackDoors := TJSONArray(Json.FindPath('openDoors.markedSecondaryDoors'));
If BackDoors <> nil then
begin
for a := 0 to BackDoors.Count - 1 do
begin
BackDoorInt := BackDoors.Items[a].AsInteger;
Case BackDoorInt of
1:QRY.ParamByName('BackDoor1').AsBoolean := True;
2:QRY.ParamByName('BackDoor2').AsBoolean := True;
3:QRY.ParamByName('BackDoor3').AsBoolean := True;
4:QRY.ParamByName('BackDoor4').AsBoolean := True;
end;
end;
end;
The json variable (TJSONData) have all the json stored inside which I use to catch the rest of variable without any issue with Json.Items[].FindPath('') function.
Any clue why TJSONArray doesn't catch it ?
Thanks!
Laurent