Example #1
0
        /// <summary>
        /// Deserialize a json array as an IEnumerable of BsonValue reading on demand TextReader
        /// </summary>
        public static IEnumerable<BsonValue> DeserializeArray(TextReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");

            var jr = new JsonReader(reader);

            return jr.DeserializeArray();
        }
Example #2
0
        /// <summary>
        /// Deserialize a json array as an IEnumerable of BsonValue
        /// </summary>
        public static IEnumerable<BsonValue> DeserializeArray(string json)
        {
            if (json == null) throw new ArgumentNullException("json");

            var sr = new StringReader(json);
            var reader = new JsonReader(sr);
            return reader.DeserializeArray();
        }
Example #3
0
        /// <summary>
        /// Deserialize a Json TextReader into a BsonValue
        /// </summary>
        public static BsonValue Deserialize(TextReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");

            var jr = new JsonReader(reader);

            return jr.Deserialize();
        }
Example #4
0
        /// <summary>
        /// Deserialize a Json string into a BsonValue
        /// </summary>
        public static BsonValue Deserialize(string json)
        {
            if (json == null) throw new ArgumentNullException("json");

            using (var sr = new StringReader(json))
            {
                var reader = new JsonReader(sr);

                return reader.Deserialize();
            }
        }
Example #5
0
        /// <summary>
        /// Deserialize a json using a StringScanner and returns BsonValue
        /// </summary>
        public static BsonValue Deserialize(StringScanner s)
        {
            if (s == null) throw new ArgumentNullException("s");

            if (s.HasTerminated) return BsonValue.Null;

            using (var sr = new StringReader(s.ToString()))
            {
                var reader = new JsonReader(sr);

                var value = reader.Deserialize();

                s.Seek((int)(reader.Position - 1));

                return value;
            }
        }