json_serializable.dart icon indicating copy to clipboard operation
json_serializable.dart copied to clipboard

@JsonSerializable() in not working in generated classes;

Open topperspal opened this issue 4 years ago • 4 comments

I want to build toJson() abd fromJson() for a generated class ( A model classs generated by some other generator ),

how can i achieve this?

topperspal avatar Oct 17 '21 16:10 topperspal

At the moment, this is not supported!

kevmoo avatar Oct 17 '21 16:10 kevmoo

a good feature request, though!

kevmoo avatar Oct 17 '21 16:10 kevmoo

YES, it will be very helpful. How we can use a generator inside another generator.

topperspal avatar Oct 19 '21 07:10 topperspal

I have created a package that generates code for form management and also creates a DataClass for the form. I want to make the DataClasses generate code for Json serializable code also and also don't want to reinvent the wheel so I want to use JsonSerializable directly inside the generated DataClass

topperspal avatar Oct 19 '21 07:10 topperspal

Don‘t understand. Can‘t you just generate @JsonKey, etc. annotations in your generator and run json_serializable over the result?

t-beckmann avatar May 21 '23 13:05 t-beckmann

See https://pub.dev/packages/build_config#adjusting-builder-ordering

kevmoo avatar May 23 '23 22:05 kevmoo