Swift 在数组中查找名称(JSON)
如何知道此数组是否包含名称“test”Swift 在数组中查找名称(JSON),swift,Swift,如何知道此数组是否包含名称“test” 如果json是数组 [{ "participantId" : 1, "player" : { "summonerName" : "8eautiful", } }, { "participantId" : 2, "player" : { "summonerName" : "test", } }] 到目前为止你尝试了什么?您应该使用Codable而不是SwiftyJSON。 for (index,subJson):(S
如果json是
数组
[{
"participantId" : 1,
"player" : {
"summonerName" : "8eautiful",
}
},
{
"participantId" : 2,
"player" : {
"summonerName" : "test",
}
}]
到目前为止你尝试了什么?您应该使用
Codable
而不是SwiftyJSON
。
for (index,subJson):(String, JSON) in json {
if subJson["player"]["summonerName"] == "test" {
print("Array contains the name test")
} else {
print("Array does not contain the name test")
}
}