I am new to elixir and I am trying to get some text from a very nested map.
So I am doing a get request to this link and I am decoding it with Jason.decode.
What I want to do is iterate over it and get every text value (sections->0->content->0->text).
In the end I just want it to be a big string of all the text values
(the link can always change so there might be more maps etc)
Thanks in advance!
Elixir provides(through erlang) some functions which can reflect upon the data-structures to check their type like
is_map/1, is_list/1, is_number/1, is_boolean/1, is_binary/1, is_nil/1etc. From docsTry to go the common data-types you will have in your response. They could be a primitive, map or list of primitives where primitives are like boolean, numeric or a string.
Write a function which tries to recursively go through the data-structure you get until it reaches a primitive and then return the stringifed primitive
Ex. for maps, go through every value(ignore key) and if the value is not a primitive, call the function recursively with that node until you reach a primitive and can return a stringified value. Similar for lists
Something like this should work: