public bool TryParse(string source, ref int index, [NotNullWhen(true)] ref JsonPath?path, [NotNullWhen(false)] out string?errorMessage) { if (path == null) { errorMessage = "Start token not found."; return(false); } index += 2; if (!JsonPathExpressionParser.TryParse <bool, JsonValue>(source, ref index, out var expression, out errorMessage)) { return(false); } if (index >= source.Length) { errorMessage = "Unexpected end of input."; return(false); } if (source[index] != ']') { errorMessage = "Expected ']'"; return(false); } index++; path.Operators.Add(new ArrayOperator(new FilterExpressionQuery(expression))); return(true); }
public string TryParse(string source, ref int index, ref JsonPath path) { index += 2; Expression <bool, JsonValue> expression; var error = JsonPathExpressionParser.Parse(source, ref index, out expression); if (error != null) { return(error); } if (index >= source.Length) { return("Unexpected end of input."); } if (source[index] != ']') { return("Expected ']'"); } index++; path.Operators.Add(new ArrayOperator(new FilterExpressionQuery(expression))); return(null); }