I’d definitely recommend to use a (de)serializer/validator lib, it’s just way to easy to forget about the rules of JSON and slip an undefined, a date or a function inside those variants! It just took me a few days to introduce such bugs in my codebase and I’m the only dev, so I can’t believe this could scale at all.
Take a look at rescript-schema or others, it’s really easy to set it up.
↧
Can I safely communicate with serialzed variants?
↧