Example #1
0
        /// <summary>
        /// Loads an <see cref="JArray"/> from a <see cref="JsonReader"/>.
        /// </summary>
        /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JArray"/>.</param>
        /// <returns>A <see cref="JArray"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public static new JArray Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!reader.Read())
                {
                    throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader.");
                }
            }

            while (reader.TokenType == JsonToken.Comment)
            {
                reader.Read();
            }

            if (reader.TokenType != JsonToken.StartArray)
            {
                throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }

            JArray a = new JArray();

            a.SetLineInfo(reader as IJsonLineInfo);

            a.ReadTokenFrom(reader);

            return(a);
        }
Example #2
0
        /// <summary>
        /// Loads an <see cref="JArray"/> from a <see cref="JsonReader"/>.
        /// </summary>
        /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JArray"/>.</param>
        /// <param name="settings">The <see cref="JsonLoadSettings"/> used to load the JSON.
        /// If this is null, default load settings will be used.</param>
        /// <returns>A <see cref="JArray"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public new static JArray Load(JsonReader reader, JsonLoadSettings settings)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!reader.Read())
                {
                    throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader.");
                }
            }

            reader.MoveToContent();

            if (reader.TokenType != JsonToken.StartArray)
            {
                throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }

            JArray a = new JArray();

            a.SetLineInfo(reader as IJsonLineInfo, settings);

            a.ReadTokenFrom(reader, settings);

            return(a);
        }
Example #3
0
        public new static JArray Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None && !reader.Read())
            {
                throw new Exception("Error reading JArray from JsonReader.");
            }
            if (reader.TokenType != JsonToken.StartArray)
            {
                throw new Exception("Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }
            JArray jArray = new JArray();

            jArray.SetLineInfo(reader as IJsonLineInfo);
            jArray.ReadTokenFrom(reader);
            return(jArray);
        }
Example #4
0
        /// <summary>
        /// Loads an <see cref="T:Newtonsoft.Json.Linq.JArray" /> from a <see cref="T:Newtonsoft.Json.JsonReader" />.
        /// </summary>
        /// <param name="reader">A <see cref="T:Newtonsoft.Json.JsonReader" /> that will be read for the content of the <see cref="T:Newtonsoft.Json.Linq.JArray" />.</param>
        /// <param name="settings">The <see cref="T:Newtonsoft.Json.Linq.JsonLoadSettings" /> used to load the JSON.
        /// If this is null, default load settings will be used.</param>
        /// <returns>A <see cref="T:Newtonsoft.Json.Linq.JArray" /> that contains the JSON that was read from the specified <see cref="T:Newtonsoft.Json.JsonReader" />.</returns>
        public static JArray Load(JsonReader reader, JsonLoadSettings settings)
        {
            if (reader.TokenType == JsonToken.None && !reader.Read())
            {
                throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader.");
            }
            reader.MoveToContent();
            if (reader.TokenType != JsonToken.StartArray)
            {
                throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)reader.TokenType));
            }
            JArray jarray = new JArray();

            jarray.SetLineInfo(reader as IJsonLineInfo, settings);
            jarray.ReadTokenFrom(reader, settings);
            return(jarray);
        }
Example #5
0
        public static JArray Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None && !reader.Read())
            {
                throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader.");
            }
            while (reader.TokenType == JsonToken.Comment)
            {
                reader.Read();
            }
            if (reader.TokenType != JsonToken.StartArray)
            {
                throw JsonReaderException.Create(reader, StringUtils.FormatWith("Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}", (IFormatProvider)CultureInfo.InvariantCulture, (object)reader.TokenType));
            }
            JArray jarray = new JArray();

            jarray.SetLineInfo(reader as IJsonLineInfo);
            jarray.ReadTokenFrom(reader);
            return(jarray);
        }