I am trying to loop through a list of bands that I have in a json file (Using Swifty-Json), for some reason when I get down to looping through the names, it returns null.
Json
Small snippet of the JSON
[
{
"Band":{
"ID":"1",
"Name":"The Kooks"
}
},
{
"Band":{
"ID":"2",
"Name":"The Killers"
}
}
]
Swift Code
for (_, value) in json {
for (_,band) in value["Band"] {
for (_,bandname) in band["Name"] {
print("Band name: \(bandname)")
}
}
}
The above code returns:
Band name: null
Band name: null
Band name: null
Band name: null
When I try this:
for (_, value) in json {
for (_,brand) in value["Band"] {
print(band)
}
}
I get this result:
The Kooks
1
The Killers
2
Can anyone tell me what the issue is?