Decoding JSON Objects into Tagged Union Types with Effect Typescript
I have JSON objects coming via HTTP in the shape
so that I can then use
I'm struggling to find a good way to compose intermediary schemas to end up with this. Ideally I don't want a transform with a big manual switch. I figured out I can do this with
but I don't know how to get the attribute through this too in a good way. Any advice appreciated!
{ attribute: string, op: string, value?: any } and i want to decode them into something like this:so that I can then use
Match.type<Op>().pipe(Match.tagsExhaustive(...) on the op field. I'm struggling to find a good way to compose intermediary schemas to end up with this. Ideally I don't want a transform with a big manual switch. I figured out I can do this with
Schema.rename to automatically parse the operators correctly into the union variants:but I don't know how to get the attribute through this too in a good way. Any advice appreciated!
