1- // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
1+ // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
@@ -19,13 +19,13 @@ class JsonKey {
1919 final Object ? defaultValue;
2020
2121 /// If `true` , generated code will throw a [DisallowedNullValueException] if
22- /// the corresponding key exists, but the value is `null` .
22+ /// the corresponding key exists, but its value is `null` .
2323 ///
2424 /// Note: this value does not affect the behavior of a JSON map *without* the
2525 /// associated key.
2626 ///
2727 /// If [disallowNullValue] is `true` , [includeIfNull] will be treated as
28- /// `false` to ensure compatibility between `toJson` and `fromJson` .
28+ /// `false` to ensure consistency between `toJson` and `fromJson` .
2929 ///
3030 /// If both [includeIfNull] and [disallowNullValue] are set to `true` on the
3131 /// same field, an exception will be thrown during code generation.
@@ -39,40 +39,41 @@ class JsonKey {
3939 /// type of the annotated field.
4040 ///
4141 /// When creating a class that supports both `toJson` and `fromJson`
42- /// (the default), you should also set [toJson] if you set [fromJson] .
43- /// Values returned by [toJson] should "round-trip" through [fromJson] .
42+ /// (the default behavior), it is recommended to also set [toJson] if
43+ /// [fromJson] is set. Values returned by [toJson] should "round-trip"
44+ /// through [fromJson] .
4445 final Function ? fromJson;
4546
4647 /// `true` if the generator should ignore this field completely.
4748 ///
4849 /// If `null` (the default) or `false` , the field will be considered for
4950 /// serialization.
5051 ///
51- /// This field is DEPRECATED use [includeFromJson] and [includeToJson]
52+ /// This field is DEPRECATED; use [includeFromJson] and [includeToJson]
5253 /// instead.
5354 @Deprecated (
5455 'Use `includeFromJson` and `includeToJson` with a value of `false` '
5556 'instead.' ,
5657 )
5758 final bool ? ignore;
5859
59- /// Used to force a field to be included (or excluded) when decoding a object
60- /// from JSON.
60+ /// Determines whether a field should be included (or excluded) when decoding
61+ /// an object from JSON.
6162 ///
62- /// `null` (the default) means the field will be handled with the default
63- /// semantics that take into account if it's private or if it can be cleanly
64- /// round-tripped to- from JSON.
63+ /// `null` (the default) means the field will be handled with default
64+ /// semantics that consider whether it's private or if it can be cleanly
65+ /// round-tripped to and from JSON.
6566 ///
66- /// `true` means the field should always be decoded, even if it's private.
67+ /// `true` forces the field to always be decoded, even if it's private.
6768 ///
68- /// `false` means the field should never be decoded.
69+ /// `false` prevents the field from being decoded.
6970 final bool ? includeFromJson;
7071
71- /// Whether the generator should include fields with `null` values in the
72+ /// Specifies whether fields with `null` values should be included in the
7273 /// serialized output.
7374 ///
74- /// If `true` , the generator should include the field in the serialized
75- /// output, even if the value is `null` .
75+ /// If `true` , the field will be included in the serialized output even if its
76+ /// value is `null` .
7677 ///
7778 /// The default value, `null` , indicates that the behavior should be
7879 /// acquired from the [JsonSerializable.includeIfNull] annotation on the
@@ -85,44 +86,43 @@ class JsonKey {
8586 /// same field, an exception will be thrown during code generation.
8687 final bool ? includeIfNull;
8788
88- /// Used to force a field to be included (or excluded) when encoding a object
89- /// to JSON.
89+ /// Determines whether a field should be included (or excluded) when encoding
90+ /// an object to JSON.
9091 ///
9192 /// `null` (the default) means the field will be handled with the default
9293 /// semantics that take into account if it's private or if it can be cleanly
9394 /// round-tripped to-from JSON.
9495 ///
95- /// `true` means the field should always be encoded, even if it's private.
96+ /// `true` forces the field to always be encoded, even if it's private.
9697 ///
97- /// `false` means the field should never be encoded.
98+ /// `false` prevents the field from being encoded.
9899 final bool ? includeToJson;
99100
100- /// The key in a JSON map to use when reading and writing values corresponding
101- /// to the annotated fields .
101+ /// The key to use in the JSON map when reading and writing values for the
102+ /// annotated field .
102103 ///
103- /// If `null` , the field name is used.
104+ /// If `null` , the field name will be used as the key .
104105 final String ? name;
105106
106- /// Specialize how a value is read from the source JSON map.
107+ /// Customizes how a value is read from the source JSON map.
107108 ///
108109 /// Typically, the value corresponding to a given key is read directly from
109110 /// the JSON map using `map[key]` . At times it's convenient to customize this
110111 /// behavior to support alternative names or to support logic that requires
111112 /// accessing multiple values at once.
112113 ///
113- /// The provided, the [Function] must be a top-level or static within the
114- /// using class.
114+ /// The provided [Function] must be either a top-level function or a static
115+ /// method within the class.
115116 ///
116117 /// Note: using this feature does not change any of the subsequent decoding
117118 /// logic for the field. For instance, if the field is of type [DateTime] we
118119 /// expect the function provided here to return a [String] .
119120 final Object ? Function (Map , String )? readValue;
120121
121- /// When `true` , generated code for `fromJson` will verify that the source
122- /// JSON map contains the associated key.
122+ /// If `true` , generated code for `fromJson` will verify that the source JSON
123+ /// map contains the associated key.
123124 ///
124- /// If the key does not exist, a [MissingRequiredKeysException] exception is
125- /// thrown.
125+ /// If the key is missing, a [MissingRequiredKeysException] will be thrown.
126126 ///
127127 /// Note: only the existence of the key is checked. A key with a `null` value
128128 /// is considered valid.
@@ -135,23 +135,23 @@ class JsonKey {
135135 /// returns a JSON-compatible value.
136136 ///
137137 /// When creating a class that supports both `toJson` and `fromJson`
138- /// (the default), you should also set [fromJson] if you set [toJson] .
139- /// Values returned by [toJson] should "round-trip" through [fromJson] .
138+ /// (the default behavior), it is recommended to also set [fromJson] if
139+ /// [toJson] is set. Values returned by [toJson] should "round-trip" through
140+ /// [fromJson] .
140141 final Function ? toJson;
141142
142- /// The value to use for an enum field when the value provided is not in the
143- /// source enum.
143+ /// The value to use for an enum field when the provided value does not match
144+ /// any of the values in the source enum.
144145 ///
145146 /// Valid only on enum fields with a compatible enum value.
146147 ///
147- /// If you want to use the value `null` when encountering an unknown value,
148- /// use the value of [JsonKey.nullForUndefinedEnumValue] instead. This is only
149- /// valid on a nullable enum field.
148+ /// To use `null` for unknown values, use [JsonKey.nullForUndefinedEnumValue] .
149+ /// This is only valid for nullable enum fields.
150150 final Enum ? unknownEnumValue;
151151
152152 /// Creates a new [JsonKey] instance.
153153 ///
154- /// Only required when the default behavior is not desired.
154+ /// Use this constructor when the default behavior is not desired.
155155 const JsonKey ({
156156 @Deprecated ('Has no effect' ) bool ? nullable,
157157 this .defaultValue,
0 commit comments