This is a great explanation for why JSON decoding needs to be exactly as complicated as it is. It's especially great for APIs returning inconsistent data types and external APIs which are frequently upgraded.
However, most of my use cases do not use public APIs or inconsistent data types, and my client and API data structures stay in sync. I pay a heavy cost for maintaining decoders compared to the capability I need from them. So, I developed a work-around using native code for my own apps. It relies on the fact that encoders/decoders are auto-generated for ports. So you declare a port, and the <20 lines of native code just gets the encoder or decoder from that port. This covers 99% of my use cases, but I have used a couple of small decoders for variable-structure error messages.
Anyway, great article. Thanks!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a great explanation for why JSON decoding needs to be exactly as complicated as it is. It's especially great for APIs returning inconsistent data types and external APIs which are frequently upgraded.
However, most of my use cases do not use public APIs or inconsistent data types, and my client and API data structures stay in sync. I pay a heavy cost for maintaining decoders compared to the capability I need from them. So, I developed a work-around using native code for my own apps. It relies on the fact that encoders/decoders are auto-generated for ports. So you declare a port, and the <20 lines of native code just gets the encoder or decoder from that port. This covers 99% of my use cases, but I have used a couple of small decoders for variable-structure error messages.
Anyway, great article. Thanks!