I use ReScript Schema for this. See data
in the Stripe integration I recently built GitHub - enviodev/rescript-stripe: 💸 Stripe Billing as a Config
The data
is a wrapper around S.object
schema which you can also use to describe transformations and field renamings. And after you got the schema, I can use it for decoding/encoding + get a list of fields and do some additional logic around this. Checkout the rescript-stripe source code to see how it’s done.