2 // Copyright (c) 2007 James Newton-King
4 // Permission is hereby granted, free of charge, to any person
5 // obtaining a copy of this software and associated documentation
6 // files (the "Software"), to deal in the Software without
7 // restriction, including without limitation the rights to use,
8 // copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 // OTHER DEALINGS IN THE SOFTWARE.
28 namespace Newtonsoft.Json.Serialization
31 /// Maps a JSON property to a .NET member.
33 public class JsonProperty
36 /// Gets the name of the property.
38 /// <value>The name of the property.</value>
39 public string PropertyName { get; set; }
42 /// Gets the <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.
44 /// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
45 public IValueProvider ValueProvider { get; set; }
48 /// Gets or sets the type of the property.
50 /// <value>The type of the property.</value>
51 public Type PropertyType { get; set; }
54 /// Gets or sets the <see cref="JsonConverter" /> for the property.
55 /// If set this converter takes presidence over the contract converter for the property type.
57 /// <value>The converter.</value>
58 public JsonConverter Converter { get; set; }
61 /// Gets a value indicating whether this <see cref="JsonProperty"/> is ignored.
63 /// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
64 public bool Ignored { get; set; }
67 /// Gets a value indicating whether this <see cref="JsonProperty"/> is readable.
69 /// <value><c>true</c> if readable; otherwise, <c>false</c>.</value>
70 public bool Readable { get; set; }
73 /// Gets a value indicating whether this <see cref="JsonProperty"/> is writable.
75 /// <value><c>true</c> if writable; otherwise, <c>false</c>.</value>
76 public bool Writable { get; set; }
79 /// Gets the member converter.
81 /// <value>The member converter.</value>
82 public JsonConverter MemberConverter { get; set; }
85 /// Gets the default value.
87 /// <value>The default value.</value>
88 public object DefaultValue { get; set; }
91 /// Gets a value indicating whether this <see cref="JsonProperty"/> is required.
93 /// <value>A value indicating whether this <see cref="JsonProperty"/> is required.</value>
94 public Required Required { get; set; }
97 /// Gets a value indicating whether this property preserves object references.
100 /// <c>true</c> if this instance is reference; otherwise, <c>false</c>.
102 public bool? IsReference { get; set; }
105 /// Gets the property null value handling.
107 /// <value>The null value handling.</value>
108 public NullValueHandling? NullValueHandling { get; set; }
111 /// Gets the property default value handling.
113 /// <value>The default value handling.</value>
114 public DefaultValueHandling? DefaultValueHandling { get; set; }
117 /// Gets the property reference loop handling.
119 /// <value>The reference loop handling.</value>
120 public ReferenceLoopHandling? ReferenceLoopHandling { get; set; }
123 /// Gets the property object creation handling.
125 /// <value>The object creation handling.</value>
126 public ObjectCreationHandling? ObjectCreationHandling { get; set; }
129 /// Gets or sets the type name handling.
131 /// <value>The type name handling.</value>
132 public TypeNameHandling? TypeNameHandling { get; set; }
135 /// Gets or sets a predicate used to determine whether the property should be serialize.
137 /// <value>A predicate used to determine whether the property should be serialize.</value>
138 public Predicate<object> ShouldSerialize { get; set; }
141 /// Gets or sets a predicate used to determine whether the property should be serialized.
143 /// <value>A predicate used to determine whether the property should be serialized.</value>
144 public Predicate<object> GetIsSpecified { get; set; }
147 /// Gets or sets an action used to set whether the property has been deserialized.
149 /// <value>An action used to set whether the property has been deserialized.</value>
150 public Action<object, object> SetIsSpecified { get; set; }
153 /// Returns a <see cref="String"/> that represents this instance.
156 /// A <see cref="String"/> that represents this instance.
158 public override string ToString()