Esempio n. 1
0
        public void Issue31_JsonPathArrayOperatorShouldWorkOnObjects_Constructed()
        {
            var json = GoessnerExamplesTest.GoessnerData;
            var path = JsonPathWith.Name("store")
                       .Name("bicycle")
                       .Array(jv => 1 == 1);

            var results = path.Evaluate(json);

            Assert.AreEqual(new JsonArray {
                "red", 19.95
            }, results);
        }
Esempio n. 2
0
        public void GoessnerExample3Constructed()
        {
            var path     = JsonPathWith.Name("store").Name();
            var expected = new JsonArray
            {
                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
                {
                    { "color", "red" },
                    { "price", 19.95 }
                }
            };
            var actual = path.Evaluate(GoessnerData);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
 public void SingleWildcardObject()
 {
     Run(JsonPathWith.Name(), "$.*");
 }
Esempio n. 4
0
 public void EmptyKey()
 {
     Run(JsonPathWith.Name(""), "$.''");
 }
Esempio n. 5
0
 public void DoubleQuotedNamedObject()
 {
     Run(JsonPathWith.Name("quoted name"), "$.\"quoted name\"");
 }
Esempio n. 6
0
 public void WeirdPropertyNameQuoted()
 {
     Run(JsonPathWith.Name("tes* \"t"), "$.\"tes* \\\"t\"");
 }
Esempio n. 7
0
 public void ChainedNameName()
 {
     Run(JsonPathWith.Name("name").Name("test"), "$.name.test");
 }
Esempio n. 8
0
 public void ChainedNameIndexedArray()
 {
     Run(JsonPathWith.Name("name").Array(4), "$.name[4]");
 }
Esempio n. 9
0
 public void SingleQuotedNamedObject()
 {
     Run(JsonPathWith.Name("quoted name"), "$.'quoted name'");
 }
Esempio n. 10
0
 public void SingleNamedObject()
 {
     Run(JsonPathWith.Name("name"), "$.name");
 }
Esempio n. 11
0
 public void EmptyKey()
 {
     Run("$.''", JsonPathWith.Name(""));
 }
Esempio n. 12
0
 public void ObjectChain()
 {
     Run("$.name.test", JsonPathWith.Name("name").Name("test"));
 }
Esempio n. 13
0
 public void ObjectKey()
 {
     Run("$.name", JsonPathWith.Name("name"));
 }