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 396 forks source link

Support `macros` to serializable JSON #1284

Open medz opened 1 year ago

medz commented 1 year ago

Please consider using macros in future Dart 3 for serialization support, there are several benefits:

  1. No need to introduce extra packages
  2. No need to run additional commands to produce auxiliary content

Macros are not officially added to Dart yet, but there is an example here https://github.com/dart-lang/language/blob/master/working/macros/example/lib/json_serializable.dart

It's too early to request this feature, but I think we can discuss feasibility and implementation issues early.

kevmoo commented 1 year ago

Macros aren't going to happen for Dart v3.0 – but hopefully v3.x. When they show up, I'll be excited to use them!

xVemu commented 3 months ago

Any news on this?

medz commented 3 months ago

@xVemu Although it may not be appropriate to post here, I would like to say that the Dart team created the 'JSON' package and used macros to complete JSON serialization.

But although the 'json' and 'json_serializable' packages are competitive, they ultimately belong to Google, but they belong to different teams.

medz commented 3 months ago

I believe that once the macro is released, the Dart team's' JSON 'package will be officially available. Perhaps the Google team will discard the 'json_serializable' after discussion`

elliotkhd commented 4 weeks ago

I believe that once the macro is released, the Dart team's' JSON 'package will be officially available. Perhaps the Google team will discard the 'json_serializable' after discussion`

Only if the "json" package supports enums and all the JsonKey features