예제 #1
0
파일: JSONRoot.cs 프로젝트: Hengle/clapotis
        public JSONRoot(string raw)
        {
            int i = 0;

            for (; i < raw.Length; i++)
            {
                if (JSONParseUtility.IsBlankChar(raw[i]) == true ||
                    raw[i] == JSONRow.JSONKeySeparator)
                {
                    continue;
                }

                int j = JSONParseUtility.IsOpener(raw[i]);

                if (j != -1)
                {
                    ++i;
                    this.child = new JSONObject(raw, ref i, raw.Length, j);
                    break;
                }
                else
                {
                    int startOffset = JSONParseUtility.DigestString(raw, ref i, raw.Length);

                    this.child = new JSONValue(raw.Substring(startOffset, i - startOffset + 1));
                    break;
                }
            }

            if (this.child != null)
            {
                this.child.Open = true;
            }
        }
예제 #2
0
        public JSONObject(string raw, ref int i, int max, int closerCharIndex)
        {
            this.closerCharIndex = closerCharIndex;

            for (; i < max; i++)
            {
                if (JSONParseUtility.IsBlankChar(raw[i]) == true ||
                    raw[i] == JSONRow.JSONKeySeparator ||
                    raw[i] == JSONRow.JSONValueSeparator)
                {
                    continue;
                }

                if (raw[i] == JSONRow.Closers[this.closerCharIndex][0])
                {
                    break;
                }

                int j = JSONParseUtility.IsOpener(raw[i]);

                if (j != -1)
                {
                    if (this.children == null)
                    {
                        this.children = new List <IJSONObject>();
                    }

                    ++i;
                    this.children.Add(new JSONObject(raw, ref i, max, j));
                }
                else
                {
                    if (this.children == null)
                    {
                        this.children = new List <IJSONObject>();
                    }

                    j = i;
                    JSONPairKeyValue element = new JSONPairKeyValue(raw, ref i, max);
                    if (i > j)
                    {
                        this.children.Add(element);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (i >= max)
            {
                this.invalidJSON = true;
            }
        }
예제 #3
0
        public JSONPairKeyValue(string raw, ref int i, int max)
        {
            for (; i < max; i++)
            {
                if (JSONParseUtility.IsBlankChar(raw[i]) == true ||
                    raw[i] == JSONRow.JSONKeySeparator)
                {
                    continue;
                }

                if (raw[i] == JSONRow.JSONValueSeparator)
                {
                    break;
                }

                if (JSONParseUtility.IsCloser(raw[i]) != -1)
                {
                    --i;
                    break;
                }

                int j = JSONParseUtility.IsOpener(raw[i]);

                if (j != -1)
                {
                    ++i;
                    this.child = new JSONObject(raw, ref i, max, j);
                }
                else
                {
                    int startOffset = JSONParseUtility.DigestString(raw, ref i, max);

                    if (this.content == null)
                    {
                        this.content = raw.Substring(startOffset, i - startOffset + 1);
                    }
                    else
                    {
                        this.child = new JSONValue(raw.Substring(startOffset, i - startOffset + 1));
                        break;
                    }
                }
            }
        }