/// <summary> /// Matches a JSON terminal value: a "string", null, a number (double value), true or false. /// No error is set if match fails. /// </summary> /// <param name="this">This <see cref="VirtualStringMatcher"/>.</param> /// <param name="value">The parsed value. Can be null.</param> /// <returns>True if a JSON value has been matched, false otherwise.</returns> public static bool TryMatchJSONTerminalValue(this VirtualStringMatcher @this, out object value) { string s; if (@this.TryMatchJSONQuotedString(out s, true)) { value = s; return(true); } double d; if (@this.TryMatchDoubleValue(out d)) { value = d; return(true); } if (@this.TryMatchText("true")) { value = true; return(true); } if (@this.TryMatchText("false")) { value = false; return(true); } value = null; return(false); }
/// <summary> /// Matches a JSON terminal value: a "string", null, a number (double value), true or false. /// This method ignores the actual value and does not set any error if match fails. /// </summary> /// <param name="this">This <see cref="VirtualStringMatcher"/>.</param> /// <returns>True if a JSON value has been matched, false otherwise.</returns> public static bool TryMatchJSONTerminalValue(this VirtualStringMatcher @this) { return(@this.TryMatchJSONQuotedString(true) || @this.TryMatchDoubleValue() || @this.TryMatchText("true") || @this.TryMatchText("false")); }