Пример #1
0
        public object Deserialize(Stream stream)
        {
            var args = new JsonObjectParseArgs()
            {
                Stream = new Internal.BufferedStream(stream, 8 * 1024),
            };

            JsonObjectParser.Parse(args);

            return(InternalDeserialize(args.InternalObject));
        }
Пример #2
0
        private bool Parse(IStream stream)
        {
            var b = stream.SeekBytesUntilVisiableChar();

            if (b == JsonEncoder.Right_Brace)
            {
                return(true);
            }
            else if (b != JsonEncoder.Double_Quotes)
            {
                throw new Errors.JsonParseFailedException(stream.Position, "dictionary name is invalid.");
            }

            var buf = stream.ReadBytesUntil(JsonEncoder.Double_Quotes);

            if (buf == null)
            {
                buf = new byte[0];
            }

            var elementName = JsonEncoder.GetString(buf);

            if (!elementName.HasValue())
            {
                throw new Errors.JsonParseFailedException(stream.Position, "dictionary element name is empty.");
            }

            stream.SeekBytesUntilEqual(JsonEncoder.Colon);

            var args = new JsonObjectParseArgs()
            {
                ExternalObject = this,
                Stream         = stream,
            };

            JsonObjectParser.Parse(args);

            if (args.InternalObject != null)
            {
                Elements = Elements.Append(new JsonDictionaryElement()
                {
                    Key   = elementName,
                    Value = args.InternalObject,
                });
            }

            return(args.Handled);
        }
Пример #3
0
        private bool Parse(IStream stream)
        {
            var args = new JsonObjectParseArgs()
            {
                ExternalObject = this,
                Stream         = stream,
            };

            JsonObjectParser.Parse(args);

            if (args.InternalObject != null)
            {
                Elements = Elements.Append(new JsonCollectionElement()
                {
                    Value = args.InternalObject
                });
            }

            return(args.Handled);
        }