google / json_serializable.dart

Generates utilities to aid in serializing to/from JSON.
https://pub.dev/packages/json_serializable
BSD 3-Clause "New" or "Revised" License
1.55k stars 397 forks source link

"createFromJson" for `@JsonSerializable` to turn on/off deserialization code generation #1382

Open ManuelRauber opened 9 months ago

ManuelRauber commented 9 months ago

Hi,

I have a class that only requires serialization to JSON but not deserialization.

For specific fields there is includeFromJson property for JsonKey.

Can we get the same for the whole class?

@JsonSerializable(createFromJson: false)
class MyClassThatOnlyNeedsSerialization {
  // ...
}

Thanks! :)