ReadJson() 공개 메소드

Reads the JSON representation of the object.
public ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) : object
reader JsonReader The to read from.
objectType System.Type Type of the object.
existingValue object The existing value of object being read.
serializer JsonSerializer The calling serializer.
리턴 object
예제 #1
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>The object value.</returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            // handle typed datasets
            DataSet ds = (objectType == typeof(DataSet))
                ? new DataSet()
                : (DataSet)Activator.CreateInstance(objectType);

            DataTableConverter converter = new DataTableConverter();

            reader.Read();

            while (reader.TokenType == JsonToken.PropertyName)
            {
                DataTable dt = ds.Tables[(string)reader.Value];
                bool exists = (dt != null);

                dt = (DataTable)converter.ReadJson(reader, typeof(DataTable), dt, serializer);

                if (!exists)
                    ds.Tables.Add(dt);

                reader.Read();
            }

            return ds;
        }
예제 #2
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
   DataSet dataSet = new DataSet();
   DataTableConverter dataTableConverter = new DataTableConverter();
   reader.Read();
   while (reader.TokenType == JsonToken.PropertyName)
   {
     DataTable table = (DataTable) dataTableConverter.ReadJson(reader, typeof (DataTable), (object) null, serializer);
     dataSet.Tables.Add(table);
     reader.Read();
   }
   return (object) dataSet;
 }
예제 #3
0
    /// <summary>
    /// Reads the JSON representation of the object.
    /// </summary>
    /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
    /// <param name="objectType">Type of the object.</param>
    /// <param name="existingValue">The existing value of object being read.</param>
    /// <param name="serializer">The calling serializer.</param>
    /// <returns>The object value.</returns>
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
      DataSet ds = new DataSet();

      DataTableConverter converter = new DataTableConverter();

      reader.Read();

      while (reader.TokenType == JsonToken.PropertyName)
      {
        DataTable dt = (DataTable)converter.ReadJson(reader, typeof (DataTable), null, serializer);
        ds.Tables.Add(dt);
      }

      return ds;
    }
예제 #4
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>The object value.</returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            DataSet ds = new DataSet();

            DataTableConverter converter = new DataTableConverter();

            reader.Read();

            while (reader.TokenType == JsonToken.PropertyName)
            {
                DataTable dt = (DataTable)converter.ReadJson(reader, typeof(DataTable), null, serializer);
                ds.Tables.Add(dt);

                reader.Read();
            }

            return(ds);
        }
예제 #5
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            DataSet            set       = (objectType == typeof(DataSet)) ? new DataSet() : ((DataSet)Activator.CreateInstance(objectType));
            DataTableConverter converter = new DataTableConverter();

            reader.Read();
            while (reader.JsonToken_0 == JsonToken.PropertyName)
            {
                DataTable table = set.Tables[(string)reader.Object_0];
                bool      flag  = table != null;
                table = (DataTable)converter.ReadJson(reader, typeof(DataTable), table, serializer);
                if (!flag)
                {
                    set.Tables.Add(table);
                }
                reader.Read();
            }
            return(set);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            DataSet            dataSet            = (objectType == typeof(DataSet)) ? new DataSet() : ((DataSet)Activator.CreateInstance(objectType));
            DataTableConverter dataTableConverter = new DataTableConverter();

            reader.Read();
            while (reader.TokenType == JsonToken.PropertyName)
            {
                DataTable dataTable = dataSet.Tables[(string)reader.Value];
                bool      flag      = dataTable != null;
                dataTable = (DataTable)dataTableConverter.ReadJson(reader, typeof(DataTable), dataTable, serializer);
                if (!flag)
                {
                    dataSet.Tables.Add(dataTable);
                }
                reader.Read();
            }
            return(dataSet);
        }
예제 #7
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return(null);
            }
            DataSet            set       = (objectType == typeof(DataSet)) ? new DataSet() : ((DataSet)Activator.CreateInstance(objectType));
            DataTableConverter converter = new DataTableConverter();

            reader.ReadAndAssert();
            while (reader.TokenType == JsonToken.PropertyName)
            {
                DataTable table = set.Tables[(string)reader.Value];
                table = (DataTable)converter.ReadJson(reader, typeof(DataTable), table, serializer);
                if (table <= null)
                {
                    set.Tables.Add(table);
                }
                reader.ReadAndAssert();
            }
            return(set);
        }