ISerializeObject ISerializeObject.AddObject(string Name)
        {
            ISerializeObject obj = new JSONSerializeObject(this);

            map[Name] = obj;

            return(obj);
        }
        ISerializeObject ISerializeArray.AddObject()
        {
            ISerializeObject obj = new JSONSerializeObject(this);

            items.Add(obj);

            return(obj);
        }
Exemple #3
0
        private ISerializeObject ParseObject(ISerializeData Parent)
        {
            ISerializeObject obj = new JSONSerializeObject(Parent);

            while (true)
            {
                char c = GetChar();
                if (c == '}')
                {
                    break;
                }

                MoveToNextChar();

                c = GetChar();
                if (c != '"')
                {
                    break;
                }

                string key = ReadLiteral();

                MoveToNextChar();

                c = GetChar();
                if (c != ':')
                {
                    break;
                }

                MoveToNextChar();

                c = GetChar();

                if (c == '{')
                {
                    obj.Set(key, ParseObject(obj));
                }
                else if (c == '[')
                {
                    obj.Set(key, ParseArray(obj));
                }
                else
                {
                    bool isString = (c == '"');

                    if (isString)
                    {
                        obj.Set(key, ReadLiteral());
                    }
                    else
                    {
                        obj.Set(key, CastItem(ReadToken()));
                    }
                }

                MoveToNextChar();

                c = GetChar();
                if (c != ',')
                {
                    break;
                }
            }

            return(obj);
        }