예제 #1
0
        /// <summary>
        /// 解析值
        /// </summary>
        /// <returns><c>true</c>, if value was parsed, <c>false</c> otherwise.</returns>
        /// <param name="data">Data.</param>
        /// <param name="startIndex">Start index.</param>
        /// <param name="endIndex">End index.</param>
        private bool ParseValue(string data, int startIndex, JSNode node, out int endIndex)
        {
            endIndex = 0;

            startIndex = SkipEmptyChar(data, startIndex);
            if (startIndex >= data.Length)
            {
                return(false);
            }

            string strVal = ParseString(data, startIndex, node, out endIndex);

            if (strVal != null)
            {
                node.SetValue(strVal);
                return(true);
            }

            string[] strAry = ParseArray(data, startIndex, node, out endIndex);
            if (strAry != null)
            {
                node.SetValue(strAry);
                return(true);
            }

            return(ParseTable(data, startIndex, node, out endIndex));
        }
예제 #2
0
        /// <summary>
        /// 解析数据
        /// </summary>
        public IElement Parse(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(null);
            }

            JSNode root = new JSNode();


            return(root);
        }
예제 #3
0
        /// <summary>
        /// 处理数据
        /// </summary>
        /// <param name="data">Data.</param>
        /// <param name="startIndex">Start index.</param>
        /// <param name="endIndex">End index.</param>
        public IElement Parse(string data, int startIndex, out int endIndex)
        {
            endIndex = 0;
            int endIdx = 0;

            int  off = startIndex;
            bool ret = false;

            // 属性名称
            string key = ParseKey(data, off, out endIdx);

            if (key == null)
            {
                return(null);
            }
            off = endIdx;

            // 连接符
            ret = ParseLinkOperator(data, off, out endIdx);
            if (ret)
            {
                off = endIdx;
            }

            JSNode node = new JSNode();

            node.Key = key;

            // 属性值
            if (!ParseValue(data, off, node, out endIdx))
            {
                return(null);
            }

            endIndex = endIdx;

            return(node);
        }