/// <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 XML that was read from the specified <see cref="JsonReader"/>.</returns>
        public static JArray Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!reader.Read())
                {
                    throw new Exception("Error reading JArray from JsonReader.");
                }
            }
            if (reader.TokenType != JsonToken.StartArray)
            {
                throw new Exception("Current JsonReader item is not an object.");
            }
            else
            {
                if (!reader.Read())
                {
                    throw new Exception("Error reading JArray from JsonReader.");
                }
            }

            JArray a = new JArray();

            a.ReadContentFrom(reader);

            return(a);
        }
Beispiel #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>
        /// <returns>A <see cref="JArray"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public static JArray Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!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 a = new JArray();

            a.SetLineInfo(reader as IJsonLineInfo);

            if (!reader.Read())
            {
                throw new Exception("Error reading JArray from JsonReader.");
            }

            a.ReadContentFrom(reader);

            return(a);
        }
Beispiel #3
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 XML that was read from the specified <see cref="JsonReader"/>.</returns>
    public static JArray Load(JsonReader reader)
    {
      if (reader.TokenType == JsonToken.None)
      {
        if (!reader.Read())
          throw new Exception("Error reading JArray from JsonReader.");
      }
      if (reader.TokenType != JsonToken.StartArray)
      {
        throw new Exception("Current JsonReader item is not an object.");
      }
      else
      {
        if (!reader.Read())
          throw new Exception("Error reading JArray from JsonReader.");
      }

      JArray a = new JArray();
      a.ReadContentFrom(reader);

      return a;
    }