Share via


JsonObject.HasKey(String) Method

Definition

Indicates whether the JsonObject has an entry with the requested key.

public:
 virtual bool HasKey(Platform::String ^ key) = IMap<Platform::String ^, IJsonValue ^>::HasKey;
bool HasKey(winrt::hstring const& key);
public bool HasKey(string key);
function hasKey(key)
Public Function HasKey (key As String) As Boolean

Parameters

key
String

Platform::String

winrt::hstring

The requested key.

Returns

Boolean

bool

true if the JsonObject has an entry with the requested key; otherwise, false.

Implements

Remarks

In C# and other languages that use .NET language projection, use the ContainsKey method instead of the HasKey method. The JsonObject class inherits HasKey from the IMap<String,IJsonValue> interface. However, this interface appears to .NET code as IDictionary<TKey,TValue> due to .NET language projection. Therefore, .NET code must use the ContainsKey method of the IDictionary<TKey,TValue> interface instead of the HasKey method of the IMap<String,IJsonValue> interface.

Applies to