I am building against a third party API from which I will be consuming data. I am curious about the best way to be handing the JSON responses I am receiving. I know it’s best practice to convert external data to structs, but some of the data structures I’m received are nested, complex and highly variable.
Should I be building pre-defined structs in which to map all incoming data (including the myriad of error messages)? I’ve seen some popular Elixir API libraries such as stripity_stripe, which dynamically convert strings in the JSON responses to atoms. This seems dangerous as they are not garbage collected, but simplifies handling the responses tremendously.
I’m looking for some guidance from anyone dealing with this issue in production.