simc / crimson

Fast, efficient and easy-to-use JSON parser and serializer for Dart.
Apache License 2.0
229 stars 6 forks source link

Ability to disable parsing/serialization from a class #7

Open Reprevise opened 1 year ago

Reprevise commented 1 year ago

It would be nice to be able to disable generating serialization or parsing code as such:

@Json(toJson: false, fromJson: true) // or some other names
class MyModel {
  // ...
}

It would also be useful to add a property for disabling the list methods. This should also be configurable from the build.yaml.

simc commented 1 year ago

I'd like to keep the library as simple and easy to use as possible. What is the advantage in disabling the generation of certain code? Tree shaking will remove it if you don't use it anyway.

Reprevise commented 1 year ago

I don't see how adding the ability to disable parsing/serialization of code makes it more complicated, especially if both are enabled by default. 99% of my classes don't require serialization so when I would write CrimsonWriter(bytes)., I would get a lot of method suggestions that I don't need. I understand its not a must have, but it is a nice-to-have.