Example #1
0
        private IList <object> DecodeArray()
        {
            o.Tag = JsonTag.JSON_ARRAY;
            var count = input.ReadVarint32();

            if (allocationLimit > -1 && count > allocationLimit)
            {
                throw new PsonException("allocation limit exceeded:" + count);
            }
            var      list = new List <object>(checked ((int)count));
            JsonNode aPos = o, aRet = o;

            o = o.CreateNode();
            bool first1 = true;

            do
            {
                list.Add(DecodeValue());
                if (first1)
                {
                    first1 = false;
                    o      = aPos.NodeBelow;
                    while (o.NextTo != null)
                    {
                        o = o.NextTo;
                    }
                }
                if (count-- > 1)
                {
                    jsonTxt.Write(',');
                    o    = o.CreateNext();
                    aPos = o;
                }
                else
                {
                    break;
                }
            } while (true);
            o = aRet;
            return(list);
        }