Comment

Comment by Zinggi

In JS, my preferred way of handling json is heavily inspired by the elm json decoding way.

I want my decoders to essentially do 2 things:

1. Transform received data into a data structure that is best suited for my app. This might involve converting lists to objects, objects to sets, parse dates etc.

2. Only succeed on valid data

This way, my application never has to deal with bad data. Also, I get to design the data structures I use, not the APIs I use. By only validating and not transforming, you are pushing more advanced validation further away from where the data was received (since you'll need to transform the data at some point anyway).

As for libraries, I want composable parsers. For TS I'd probably use: https://github.com/paperhive/fefe/

parent Zinggi 6 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton