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

request: include common interface to allow us to indicate object supports toJson #1376

Open tylandercasper opened 10 months ago

tylandercasper commented 10 months ago

I have a lot of different projects that need to know (or require) if an object is serializable to json. I've got an Iserializable interface, but as the projects grow and especially as I'm starting to try to seperate some of them into publishable packages, the question of where to put the interface is getting more and more convoluted.

At this point, I'm probably just going to make a to_json_interface package that does nothing but provide that one interface.

It would be great if json_serializable_annotation already included something like this as I'm sure other packages would like the ability to know this as well.