swift - 在数组中查找名称 (JSON)
问题描述
[{
"participantId" : 1,
"player" : {
"summonerName" : "8eautiful",
}
},
{
"participantId" : 2,
"player" : {
"summonerName" : "test",
}
}]
你怎么知道这个数组是否包含名称“test”?
使用 swiftyjson
解决方案
如果 json 是一个Array
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")
}
}
推荐阅读
- java - 返回一个节点,其自身及其子节点在整个树中的总和最大,但即使当前总和较小,也会更新最大总和
- node.js - 为什么我得到一个 req.app.locals.something 未定义?
- javascript - 我怎样才能让我的标题背景在滚动时变成白色?
- java - Apache Syncope 找不到指定的路径文件错误
- apache-nifi - 有没有办法禁用 NiFi 中的所有存储库(例如 FlowFile Repo、Content Repo 等)?
- numpy - 在 for 循环中数组大小的 Numpy 问题
- javascript - 如何修复此算法以在 AST 中创建嵌套部分
- flutter - Lottie 资产加载到网络上但在我的移动设备上
- angular - Ag-Grid 内部的模态渲染
- php - 如何确保 laravel 中的列名相同?