예제 #1
0
        /// <summary>
        /// Test array with array with property with property jPath
        /// </summary>
        public void TestArrayWithArrayWithPropertyWithPropertyPath()
        {
            #region Prepare

            List <LazyJsonPathNode>?jsonPathNodeList = null;

            #endregion Prepare

            #region Execute

            jsonPathNodeList = LazyJsonPath.Parse("$.[0].[1].ChildItem.OtherItem");

            #endregion Execute

            #region Assert

            Assert.IsTrue(jsonPathNodeList.Count == 5);
            Assert.IsTrue(jsonPathNodeList[0].Type == LazyJsonPathType.Property);
            Assert.IsTrue(jsonPathNodeList[1].Type == LazyJsonPathType.ArrayIndex);
            Assert.IsTrue(jsonPathNodeList[2].Type == LazyJsonPathType.ArrayIndex);
            Assert.IsTrue(jsonPathNodeList[3].Type == LazyJsonPathType.Property);
            Assert.IsTrue(jsonPathNodeList[4].Type == LazyJsonPathType.Property);

            Assert.IsTrue(((LazyJsonPathArrayIndex)jsonPathNodeList[1]).Index == "0");
            Assert.IsTrue(((LazyJsonPathArrayIndex)jsonPathNodeList[2]).Index == "1");

            #endregion Assert
        }
예제 #2
0
        /// <summary>
        /// Test root jPath
        /// </summary>
        public void TestRootPath()
        {
            #region Prepare

            List <LazyJsonPathNode>?jsonPathNodeList = null;

            #endregion Prepare

            #region Execute

            jsonPathNodeList = LazyJsonPath.Parse("$");

            #endregion Execute

            #region Assert

            Assert.IsTrue(jsonPathNodeList.Count == 1);
            Assert.IsTrue(jsonPathNodeList[0].Type == LazyJsonPathType.Property);

            #endregion Assert
        }