Hey Nicole,
If you use a
TJSONData first, then you have access to
FindPath, which will return a
nil if the node/path, is not present, which is what I think you're getting.
This has been my way of avoiding issues when some fields are missing:
var
JSONData: TJSONData;
JSONObject: TJSONObject;
begin
{ ... }
JSONData:= JSONArray.Items[i] as TJSONData;
JSONObject:= JSONData.FindPath('stockExchange');
if Assigned(JSONObject) then
StockExchange:= JSONObject.AsString;
{ ... }
end;
I think this should solve your problem.
But please double check my code. I did not run this on the IDE, I just typed from memory.
Cheers,
Gus