I’m using the JSON nuget to interface with .json files, and I’ve gotten pretty far using the serialization and deserialization methods. However, I’m trying to determine if a key exists within a JObject, with a basic example shown below:
string key = "Example";
string value = "value";
JObject temp = new JObject();
temp.Add(key, new JValue(value));
if (temp.Contains(key))
{
//Success
return null;
}
This is just a basic test to see if the Contains() method can detect the newly added key within the JObject. Unfortunately, the program never enters the if statement and I can’t figure out why. I feel like I must have a misunderstanding of what the method is looking for, or how it uses the “name” input parameter.
One workaround is to do a foreach loop and manually compare each key within the JObject to a known string, but I’m trying to avoid that if possible.
Any help would be appreciated, thanks.