How can I check if the key (int)myJsonData[0]["listings"][i]["names"]["firstName"] exists in my json file (which is pulled from server)? I use myJsonData = JsonMapper.ToObject("[" + webRequest.downloadHandler.text.Trim() + "]"); to handle the Json data
and then I use
to add key value pairs to a dictionary/list called itemData.
My issue is that I get KeyNotFoundException: The given key was not present in the dictionary if, for example, the key value pair ["listings"]["names"]["firstName"] doesn't exist in the Json object (sometime it wont, it is a dynamic json file.)
is there a simple method to say, if this key exists - proceed with function?
How can I check if the key
(int)myJsonData[0]["listings"][i]["names"]["firstName"]
exists in my json file (which is pulled from server)? I usemyJsonData = JsonMapper.ToObject("[" + webRequest.downloadHandler.text.Trim() + "]");
to handle the Json data and then I usemyJsonData.Add(new myClass( (int)itemData[0]["listings"][i]["names"]["firstName"]
to add key value pairs to a dictionary/list called itemData.
My issue is that I get
KeyNotFoundException: The given key was not present in the dictionary
if, for example, the key value pair["listings"]["names"]["firstName"]
doesn't exist in the Json object (sometime it wont, it is a dynamic json file.)is there a simple method to say, if this key exists - proceed with function?