public void FilterOnNonExistingPropertyEqualNull_ReturnsCorrectResult()
        {
            string input = TestDataLoader.BooksWithNulls();

            ExpressionList expression = ExpressionList.TokenizeAndParse("$.books[?(@.plumbus == null)]");

            IReadOnlyList <JsonElement> result = JsonPath.ExecutePath(expression, input);

            Assert.Equal(4, result.Count);
        }
        public void FilterOnNumberEqualNull_ReturnsCorrectResult()
        {
            string input = TestDataLoader.BooksWithNulls();

            ExpressionList expression = ExpressionList.TokenizeAndParse("$.books[?(@.price== null)]");

            IReadOnlyList <JsonElement> result = JsonPath.ExecutePath(expression, input);

            Assert.Equal(1, result.Count);
            Assert.Equal(JsonValueKind.Object, result[0].ValueKind);
            Assert.Equal("Sayings of the Century", result[0].EnumerateObject().FirstOrDefault(x => x.Name == "title").Value.GetString());
        }
        public void FilterOnBooksObject_ReturnsCorrectResult(string path, params string[] expected)
        {
            string         input               = TestDataLoader.BooksObject();
            ExpressionList expression          = ExpressionList.TokenizeAndParse(path);
            IReadOnlyList <JsonElement> result = JsonPath.ExecutePath(expression, input);

            Assert.Equal(expected.Length, result.Count);
            string[] resultJsons = result.Select(x => JsonSerializer.Serialize(x)).Select(x => x.RemoveWhiteSpace()).ToArray();

            foreach (string e in expected)
            {
                Assert.Contains(_bookJsons[e], resultJsons);
            }
        }
        public void LessThanOrEqualFilterOnIntWithDecimal_ReturnsCorrectResult()
        {
            string input = @"
                {
                    ""object"": {
                        ""arrays"": [ { ""amount"": 10 } ]
                    }
                }
            ";

            ExpressionList expression = ExpressionList.TokenizeAndParse("$.object.arrays[?(@.amount >= 10.0)]");

            IReadOnlyList <JsonElement> result = JsonPath.ExecutePath(expression, input);

            Assert.Equal(1, result.Count);
        }