JObjectExtensions.GetEnum method

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Json.Extensions
Assembly Skybrud.Essentials.dll

GetEnum<T>(JObject, string)

Extension method

Gets an enum of type T from the token matching the specified path.

public static T GetEnum<T>(this JObject obj, string path)

Type Parameters

T

The type of the enum.

Parameters

obj JObject

The instance of JObject .

path String

A String that contains a JPath expression.

Returns

T

An instance of T.

GetEnum<T>(JObject, string, T)

Extension method

Gets an enum of type T from the token matching the specified path.

public static T GetEnum<T>(this JObject obj, string path, T fallback)

Type Parameters

T

The type of the enum.

Parameters

obj JObject

The instance of JObject .

path String

A String that contains a JPath expression.

fallback T

The fallback value if the value in the JSON couldn't be parsed.

Returns

T