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

Add JsonKey.includeFromJson/includeToJson - allow explicit control of serialization #1256

Closed kevmoo closed 1 year ago

kevmoo commented 1 year ago

...and deprecate JsonKey.ignore

Fixes https://github.com/google/json_serializable.dart/issues/24 Fixes https://github.com/google/json_serializable.dart/issues/274 Fixes https://github.com/google/json_serializable.dart/issues/537 Fixes https://github.com/google/json_serializable.dart/issues/569 Fixes https://github.com/google/json_serializable.dart/issues/797 Fixes https://github.com/google/json_serializable.dart/issues/1100 Fixes https://github.com/google/json_serializable.dart/issues/1244

ImadBouirmane commented 1 year ago

Useful, I will use it, can I have a simplify description about this new improvement on Json abilities in our codes !

ValentinVignal commented 1 year ago

Is there any reason you use this FieldUsage enum with 4 values instead of 2 boolean parameters (ex: ignoreInFromJson and ignoreInToJson) ?

kevmoo commented 1 year ago

@ValentinVignal great question! It comes down to terseness. I believe it's easier to document and explain...at least a bit. I realize it's the same state-space. Happy to discuss further, though.

feduke-nukem commented 1 year ago

I wonder, how I am able to use these fixes? @kevmoo

kevmoo commented 1 year ago

@feduke-nukem ...what do you mean?

feduke-nukem commented 1 year ago

@feduke-nukem ...what do you mean?

I am not able to find JsonKey.writeOnly and others mentoned here in the latest version of package. Am I misunderstanding something?

kevmoo commented 1 year ago

@feduke-nukem – that's because I haven't published it yet! Ha! Let me see if I can do that today

feduke-nukem commented 1 year ago

@feduke-nukem – that's because I haven't published it yet! Ha! Let me see if I can do that today

That will be really nice 😁

kevmoo commented 1 year ago

@feduke-nukem – that's because I haven't published it yet! Ha! Let me see if I can do that today

That will be really nice 😁

Published!

feduke-nukem commented 1 year ago

@feduke-nukem – that's because I haven't published it yet! Ha! Let me see if I can do that today

That will be really nice 😁

Published!

Thanks!