I have the folowing if
statement which works fine:
if (json1.ContainsKey("key2"))
{
// do something here.
}
json1
contains the following:
{
"key1": {
"key1_1": "value1_1",
"key1_2": "value1_2",
"key1_3": [
"value1_3_2",
"value1_3_2"
],
"key1_1": "value1_1"
},
"key2": "value2_1",
"key3": "value3_1"
}
I can get specific values from the keys like this:
console.writeline(json1["key2"]);
console.writeline(json1["key1"]["key1_3"][0]);
I am now trying to check if key1_3
exists, but don't know how to.
I have tried the following code examples and they do not work:
if (json1.ContainsKey("key1_3"))
{
// do something here.
}
if (json1["key1"].ContainsKey("key1_3"))
{
// do something here.
}
How do I check if a nested key exists such as key1_3