Parsing JSON requests with zod

In the spirit of parse, don’t validate, I’ve started using zod as my go-to JSON parsing library in Typescript. JSON.parse, or something like response.json() gives you an valid JS object but in your application you’re usually working with a richer set of types that will almost always require validation. The idea is to parse the JS object into a Typescript object. While there are powerful parser combinator libaries for JavaScript, zod takes a simpler approach by only allowing you to JSON objects1 and only exposing a few (and very sane) set of parsers for each field....

<span title='2023-02-19 16:06:56 +0530 IST'>February 19, 2023</span>