You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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 dataand then I use
myJsonData.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?
The text was updated successfully, but these errors were encountered: