JTokenUtility.AsNumber method

Returns the token as a JValue if it corresponds to a number.

public static JValue? AsNumber(this JToken? jToken)

Return Value

This method returns null if the JToken is null or if it doesn’t contain a number.

Remarks

Use this method to “filter out” non-numeric tokens without losing any precision on the number itself (since numeric representations of the number could lose precision).

See Also