Skip to content

Commit d49a5f2

Browse files
authored
Fix bug when JsonKey.includeToJson is false (#1281)
Fixes #1280
1 parent 8f31d52 commit d49a5f2

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

json_serializable/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.6.1
2+
3+
- Fix bug when `JsonKey.includeToJson` is `false`.
4+
15
## 6.6.0
26

37
- Support for `JsonKey.includeFromJson` and `JsonKey.includeToJson`.

json_serializable/lib/src/generator_helper.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@ extension on KeyConfig {
151151

152152
bool get explicitYesToJson => includeToJson == true;
153153

154-
bool get explicitNoToJson => includeFromJson == false;
154+
bool get explicitNoToJson => includeToJson == false;
155155
}

json_serializable/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_serializable
2-
version: 6.6.0
2+
version: 6.6.1
33
description: >-
44
Automatically generate code for converting to and from JSON by annotating
55
Dart classes.

json_serializable/test/field_matrix_test.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ const _expectedResult = {
4040
'without': {'aField': null, 'field': null, 'zField': null}
4141
},
4242
'ToJsonTrueFromJsonFalsePublic: field: null': {
43-
'with': {'aField': null, 'zField': null},
44-
'without': {'aField': null, 'zField': null}
43+
'with': {'aField': null, 'field': null, 'zField': null},
44+
'without': {'aField': null, 'field': null, 'zField': null}
4545
},
4646
'ToJsonFalseFromJsonNullPublic: field: 42': {
47-
'with': {'aField': null, 'field': 42, 'zField': null},
48-
'without': {'aField': null, 'field': null, 'zField': null}
47+
'with': {'aField': null, 'zField': null},
48+
'without': {'aField': null, 'zField': null}
4949
},
5050
'ToJsonFalseFromJsonTruePublic: field: 42': {
51-
'with': {'aField': null, 'field': 42, 'zField': null},
52-
'without': {'aField': null, 'field': null, 'zField': null}
51+
'with': {'aField': null, 'zField': null},
52+
'without': {'aField': null, 'zField': null}
5353
},
5454
'ToJsonFalseFromJsonFalsePublic: field: null': {
5555
'with': {'aField': null, 'zField': null},
@@ -76,16 +76,16 @@ const _expectedResult = {
7676
'without': {'aField': null, 'field': null, 'zField': null}
7777
},
7878
'ToJsonTrueFromJsonFalsePrivate: _field: null': {
79-
'with': {'aField': null, 'zField': null},
80-
'without': {'aField': null, 'zField': null}
79+
'with': {'aField': null, 'field': null, 'zField': null},
80+
'without': {'aField': null, 'field': null, 'zField': null}
8181
},
8282
'ToJsonFalseFromJsonNullPrivate: _field: null': {
8383
'with': {'aField': null, 'zField': null},
8484
'without': {'aField': null, 'zField': null}
8585
},
8686
'ToJsonFalseFromJsonTruePrivate: _field: 42': {
87-
'with': {'aField': null, 'field': 42, 'zField': null},
88-
'without': {'aField': null, 'field': null, 'zField': null}
87+
'with': {'aField': null, 'zField': null},
88+
'without': {'aField': null, 'zField': null}
8989
},
9090
'ToJsonFalseFromJsonFalsePrivate: _field: null': {
9191
'with': {'aField': null, 'zField': null},

json_serializable/test/field_matrix_test.field_matrix.g.dart

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)