public void GoessnerExample9Constructed() { var path = JsonPathWith.Search("book").Array(jv => jv.Name("price") < 10); Console.WriteLine(path); var expected = new JsonArray { new JsonObject { { "category", "reference" }, { "author", "Nigel Rees" }, { "title", "Sayings of the Century" }, { "price", 8.95 } }, new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } } }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void GoessnerExample8Constructed() { var path = JsonPathWith.Search("book").Array(jv => jv.HasProperty("isbn")); var expected = new JsonArray { new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } }, new JsonObject { { "category", "fiction" }, { "author", "J. R. R. Tolkien" }, { "title", "The Lord of the Rings" }, { "isbn", "0-395-19395-8" }, { "price", 22.99 } } }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void SingleWildcardSearch() { var text = "$..*"; var expected = JsonPathWith.Search(); var actual = JsonPath.Parse(text); Assert.AreEqual(expected, actual); }
public void DoubleQuotedNamedSearch() { var text = "$..\"quoted name\""; var expected = JsonPathWith.Search("quoted name"); var actual = JsonPath.Parse(text); Assert.AreEqual(expected, actual); }
public void SingleNamedSearch() { var text = "$..name"; var expected = JsonPathWith.Search("name"); var actual = JsonPath.Parse(text); Assert.AreEqual(expected, actual); }
public void GoessnerExample2Constructed() { var path = JsonPathWith.Search("author"); var expected = new JsonArray { "Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien" }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void GoessnerExample6BConstructed() { var path = JsonPathWith.Search("book").Array(new Slice(-1, null)); var expected = new JsonArray { new JsonObject { { "category", "fiction" }, { "author", "J. R. R. Tolkien" }, { "title", "The Lord of the Rings" }, { "isbn", "0-395-19395-8" }, { "price", 22.99 } } }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void GoessnerExample5Constructed() { var path = JsonPathWith.Search("book").Array(2); var expected = new JsonArray { new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } } }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void GoessnerExample7BConstructed() { var path = JsonPathWith.Search("book").Array(new Slice(null, 2)); var expected = new JsonArray { new JsonObject { { "category", "reference" }, { "author", "Nigel Rees" }, { "title", "Sayings of the Century" }, { "price", 8.95 } }, new JsonObject { { "category", "fiction" }, { "author", "Evelyn Waugh" }, { "title", "Sword of Honour" }, { "price", 12.99 } } }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void GoessnerExample10Constructed() { var path = JsonPathWith.Search(); var expected = new JsonArray { new JsonObject { { "book", new JsonArray { new JsonObject { { "category", "reference" }, { "author", "Nigel Rees" }, { "title", "Sayings of the Century" }, { "price", 8.95 } }, new JsonObject { { "category", "fiction" }, { "author", "Evelyn Waugh" }, { "title", "Sword of Honour" }, { "price", 12.99 } }, new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } }, new JsonObject { { "category", "fiction" }, { "author", "J. R. R. Tolkien" }, { "title", "The Lord of the Rings" }, { "isbn", "0-395-19395-8" }, { "price", 22.99 } } } }, { "bicycle", new JsonObject { { "color", "red" }, { "price", 19.95 } } } }, new JsonArray { new JsonObject { { "category", "reference" }, { "author", "Nigel Rees" }, { "title", "Sayings of the Century" }, { "price", 8.95 } }, new JsonObject { { "category", "fiction" }, { "author", "Evelyn Waugh" }, { "title", "Sword of Honour" }, { "price", 12.99 } }, new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } }, new JsonObject { { "category", "fiction" }, { "author", "J. R. R. Tolkien" }, { "title", "The Lord of the Rings" }, { "isbn", "0-395-19395-8" }, { "price", 22.99 } } }, new JsonObject { { "category", "reference" }, { "author", "Nigel Rees" }, { "title", "Sayings of the Century" }, { "price", 8.95 } }, "reference", "Nigel Rees", "Sayings of the Century", 8.95, new JsonObject { { "category", "fiction" }, { "author", "Evelyn Waugh" }, { "title", "Sword of Honour" }, { "price", 12.99 } }, "fiction", "Evelyn Waugh", "Sword of Honour", 12.99, new JsonObject { { "category", "fiction" }, { "author", "Herman Melville" }, { "title", "Moby Dick" }, { "isbn", "0-553-21311-3" }, { "price", 8.99 } }, "fiction", "Herman Melville", "Moby Dick", "0-553-21311-3", 8.99, new JsonObject { { "category", "fiction" }, { "author", "J. R. R. Tolkien" }, { "title", "The Lord of the Rings" }, { "isbn", "0-395-19395-8" }, { "price", 22.99 } }, "fiction", "J. R. R. Tolkien", "The Lord of the Rings", "0-395-19395-8", 22.99, new JsonObject { { "color", "red" }, { "price", 19.95 } }, "red", 19.95 }; var actual = path.Evaluate(GoessnerData); Assert.AreEqual(expected, actual); }
public void EmptySearch() { Run(JsonPathWith.Search(""), "$..''"); }
public void EmptySearch() { Run("$..''", JsonPathWith.Search("")); }