Swift Alamofire取得相等的资料

时间:2018-08-21 13:53:40

标签: ios json swift alamofire

您好,我通过Alamofire获取json数据,并得到了这样的信息:

{
     "prices": [
{
  "id": 1,
  "value": 1.327,
  "stationId": 24,
  "type": 0,
  "score": 5
},
{
  "id": 2,
  "value": 1.319,
  "stationId": 25,
  "type": 0,
  "score": 4
},...],

      "stations": [
{
  "id": 24,
  "name": "...",
  "address": "...",
  "brandId": 1,
  "location": ".."
},
{
  "id": 25,
  "name": "..",
  "address": "..",
  "brandId": 1,
  "location": ".."
},..],

         "brands": [
{
  "id": 6,
  "name": "AGIP"
},
{
  "id": 2,
  "name": "EKO"
}, ...]

如何获取“类型”为0的所有数据

然后,当获取所有具有类型的数据时,请比较价格站和品牌的ID,并将其放入数组或字典中

1 个答案:

答案 0 :(得分:0)

您可以使用AlamofireObjectMapper窗格来映射您的响应,然后可以使用for周期来过滤此对象。