title: Swift - Parse certain data
body: <p>Need to extract the data of <code>desc</code> from the below API response. From that i need to extract every <code>a</code> and <code>b</code>, so that i can use that in for a math addition app.</p>
  
  <pre><code>data from the server
  
   [
      {
          "id": 226,
          "name": "chorename",
          "desc": "{\n  \"questions\" : [\n    {\n      \"b\" : 2,\n      \"a\" : 1\n    },\n    {\n      \"b\" : 3,\n      \"a\" : 2\n    },\n    {\n      \"b\" : 2,\n      \"a\" : 8\n    },\n    {\n      \"b\" : 9,\n      \"a\" : 7\n    },\n    {\n      \"b\" : 3,\n      \"a\" : 6\n    }\n  ],\n  \"operation\" : \"addition\"\n}",
          "reward": "1.00",
          "sched": "2018-04-19T15:54:24.657644+08:00",
          "parent": "shit",
          "type": "homework",
          "child": "",
          "occurrence": {
              "name": "once"
          },
          "status": {
              "name": "ongoing"
          },
          "date_created": "2018-04-23T14:16:35.739436+08:00",
          "date_modified": "2018-04-23T14:16:35.790237+08:00"
      }
  ]
  code on getting request
  func demoApi1() {
          Alamofire.request("", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil).responseJSON { (response:DataResponse&lt;Any&gt;) in
  
              switch(response.result) {
              case .success(_):
                  guard let json = response.result.value as! [[String:Any]]? else{ return}
                  print("Ang Response: , \(json)")
  
                  for item in json {
  
                      var a = self.getAllDetail.append(item )
                      print("shit:" , a)
  
  
                      // if let title = item["title"] as? String {
                      //   self.titleArray.append(title)
                      // }
  
                  }
                  if !self.getAllDetail.isEmpty{
                      DispatchQueue.main.async {
  
                      }
                  }
                  break
  
              case .failure(_):
                  print("Error")
                  break
  
              }
          }
  
      }
  
  let devices = assign "a" here
          let randomIndex = Int(arc4random_uniform(UInt32(devices.count)))
          let randomItem = devices[randomIndex]
          print("random item:" ,randomItem)
  
  
          let device2 = //assign "b" here
          let randomIndex1 = Int(arc4random_uniform(UInt32(devices.count)))
          let randomItem1 = device2[randomIndex]
  </code></pre>
  
  <p><strong>API Response:</strong></p>
  
  <pre><code> Ang Response [["status": {
      name = ongoing;
  }, "sched": 2018-04-10T14:22:00+08:00, "desc": asdasdasdsa, "id": 224, "reward": 1.00, "parent": das, "child": dasdas, "date_created": 2018-04-19T15:54:24.657644+08:00, "name": sad, "occurrence": {
      name = once;
  }, "type": , "date_modified": 2018-04-19T15:54:24.703520+08:00], ["status": {
      name = ongoing;
  }, "sched": 2018-04-19T15:54:24.657644+08:00, "desc": {
    "questions" : [
      {
        "b" : 2,
        "a" : 1
      },
      {
        "b" : 3,
        "a" : 2
      },
      {
        "b" : 2,
        "a" : 8
      },
      {
        "b" : 9,
        "a" : 7
      },
      {
        "b" : 3,
        "a" : 6
      }
    ],
    "operation" : "addition"
  }, "id": 226, "reward": 1.00, "parent": shit, "child": , "date_created": 2018-04-23T14:16:35.739436+08:00, "name": chorename, "occurrence": {
      name = once;
  }, "type": homework, "date_modified": 2018-04-23T14:16:35.790237+08:00]]
  </code></pre>