/// <summary> /// Gets the <see cref="bool"/> value of the token matching the specified <paramref name="path"/>, or /// <paramref name="fallback"/> of a matching token isn't found or the token value can not be parsed to a /// boolean value. /// </summary> /// <param name="array">The parent array.</param> /// <param name="path">A <see cref="string"/> that contains a JPath expression.</param> /// <param name="fallback">The fallback value.</param> /// <returns>An instance of <see cref="bool"/>.</returns> public static bool GetBoolean(this JArray array, string path, bool fallback) { return(JsonTokenUtils.GetBoolean(array?.SelectToken(path), fallback)); }
/// <summary> /// Gets the <see cref="bool"/> value of the token matching the specified <paramref name="path"/>, or /// <paramref name="fallback"/> if <paramref name="path"/> doesn't match a token. /// </summary> /// <param name="obj">The parent object.</param> /// <param name="path">A <see cref="string"/> that contains a JPath expression.</param> /// <param name="fallback">The fallback value.</param> /// <returns>An instance of <see cref="bool"/>.</returns> public static bool GetBoolean(this JObject obj, string path, bool fallback) { return(JsonTokenUtils.GetBoolean(obj?.SelectToken(path), fallback)); }
/// <summary> /// Returns the <see cref="bool"/> value of the item at the specified <paramref name="index"/> in the array, or /// <paramref name="fallback"/> of a matching token isn't found or the token value can not be parsed to a /// boolean value. /// </summary> /// <param name="array">The parent array.</param> /// <param name="index">The index of the token.</param> /// <param name="fallback">The fallback value.</param> /// <returns>An instance of <see cref="bool"/>.</returns> public static bool GetBoolean(this JArray array, int index, bool fallback) { return(JsonTokenUtils.GetBoolean(array?[index], fallback)); }