So im trying to get data of a list within a list within a list
%{
"items" => [
%{
"attackLog" => [],
"capitalTotalLoot" => 0,
"defenseLog" => [
%{
"attackCount" => 6,
"attacker" => %{
"badgeUrls" => %{
"large" => "https://api-assets.clashofclans.com/badges/512/5WcJ_xhmnpgB30TUy91VB1aC8RkfCBxuYI1PCzQdFcE.png",
"medium" => "https://api-assets.clashofclans.com/badges/200/5WcJ_xhmnpgB30TUy91VB1aC8RkfCBxuYI1PCzQdFcE.png",
"small" => "https://api-assets.clashofclans.com/badges/70/5WcJ_xhmnpgB30TUy91VB1aC8RkfCBxuYI1PCzQdFcE.png"
},
So basically, the first list where all the data is in, is called items
, then within that, there is another list called defenseLog
, and in there, there is another called attacker
- and I want all of that data from there.
I tried the following so far:
def main(tag) do
data = fetch_data_from_api(tag)
Kernel.get_in(data, ["items", "defenseLog", "attacker"])
end
but this errors:
* (ArgumentError) the Access calls for keywords expect the key to be an atom, got: "defenseLog"