protected override object SubImport(JsonReader reader) { if (reader == null) throw new ArgumentNullException("reader"); reader.ReadToken(JsonTokenClass.Object); object o = Activator.CreateInstance(_type); while (reader.TokenClass != JsonTokenClass.EndObject) { string memberName = reader.ReadMember(); PropertyDescriptor property = _properties[memberName]; if (property != null) property.SetValue(o, reader.Get(property.PropertyType)); } return o; }
protected override object SubImport(JsonReader reader) { if (reader == null) throw new ArgumentNullException("reader"); if (reader.Token != JsonToken.Object) throw new JsonSerializationException(string.Format("Found {0} where expecting an object.", reader.Token)); reader.Read(); object o = Activator.CreateInstance(_type); while (reader.Token != JsonToken.EndObject) { string memberName = reader.Text; reader.Read(); PropertyDescriptor property = _properties[memberName]; if (property != null) property.SetValue(o, reader.Get(property.PropertyType)); } return o; }
protected override object SubImport(JsonReader reader) { if (reader == null) throw new ArgumentNullException("reader"); if (reader.TokenClass != JsonTokenClass.Array) throw new JsonSerializationException(string.Format("Found {0} where expecting an array.", reader.TokenClass)); reader.Read(); Type elementType = _arrayType.GetElementType(); ArrayList list = new ArrayList(); while (reader.TokenClass != JsonTokenClass.EndArray) list.Add(reader.Get(elementType)); return list.ToArray(elementType); }