I'm trying to communicate with a kubernetes API and as a result, I need to decode very long, nested and varied json results.
I think it would be way more effective to pass the results of those queries as a nested dict (similar to how you'd do it in Python) rather than building complex types and decoders for each query. It would also be much less laborious to write and maintain. However, I'm having a headache trying to understand how to decode json, let alone recursively.
#Decode json to nested dict
1 messages · Page 1 of 1 (latest)
one option is you can decode it as a Dict(String, Dynamic) and just keep drilling down into keys with proper types. the nice thing about decoders is you can just selectively reach into things. https://hexdocs.pm/decode/decode/zero.html#at one alternative would be with something like decode/zero.{at} you can reach into key paths with this. that'd probably be my suggestion