Table of Contents

Method TryGetTraits

Namespace
Xunit.Sdk
Assembly
xunit.v3.common.dll

TryGetTraits(IReadOnlyDictionary<string, object?>, string, bool)

Tries to get a trait dictionary value from a deserialized JSON object.

public static IReadOnlyDictionary<string, IReadOnlyCollection<string>>? TryGetTraits(IReadOnlyDictionary<string, object?> obj, string key, bool defaultEmptyDictionary = true)

Parameters

obj IReadOnlyDictionary<string, object>

The deserialized JSON object

key string

The key for the value

defaultEmptyDictionary bool

Flag to indicate if a default empty dictionary should be returned instead of null

Returns

IReadOnlyDictionary<string, IReadOnlyCollection<string>>

TryGetTraits(object?)

Tries to get a string value from a deserialized JSON value.

public static IReadOnlyDictionary<string, IReadOnlyCollection<string>>? TryGetTraits(object? value)

Parameters

value object

The deserialized JSON value

Returns

IReadOnlyDictionary<string, IReadOnlyCollection<string>>

Returns the value if present; null, otherwise.