Table of Contents

Method TryGetString

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

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

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

public static string? TryGetString(IReadOnlyDictionary<string, object?> obj, string key, bool defaultEmptyString = false)

Parameters

obj IReadOnlyDictionary<string, object>

The deserialized JSON object

key string

The key for the value

defaultEmptyString bool

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

Returns

string

Returns the value if present; null, otherwise.

TryGetString(object?, bool)

Tries to get an long value from a deserialized JSON value.

public static string? TryGetString(object? value, bool defaultEmptyString = false)

Parameters

value object

The deserialized JSON value

defaultEmptyString bool

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

Returns

string

Returns the value if present; null, otherwise.