explicitToJson property

bool? explicitToJson
final

If true, generated toJson methods will explicitly call toJson on nested objects.

When using JSON encoding support in dart:convert, toJson is automatically called on objects, so the default behavior (explicitToJson: false) is to omit the toJson call.

Example of explicitToJson: false (default)

Map<String, dynamic> toJson() => {'child': child};

Example of explicitToJson: true

Map<String, dynamic> toJson() => {'child': child?.toJson()};

Implementation

final bool? explicitToJson;