Take argonaut
for example, in some of our projects, when there is the need to handle JSON, people will use argonaut for that, and hardcoding the fields, like:
implicit def AddressCodecJson: CodecJson[Address] =
casecodec3(Address.apply, Address.unapply)("street", "number", "post_code")
If there is a big case class, the list will be very long:
implicit def AddressCodecJson: CodecJson[Address] =
casecodec12(Address.apply, Address.unapply)("street", "number", "post_code", "...", "...", "...", "...", "...", "...", "...", "...", "...")
My question is why do we need to hardcode them, rathar than get the field by reflection?
Is there any technical problem, or people just don't like using reflection when design Scala libraries?
Aucun commentaire:
Enregistrer un commentaire