Я пытаюсь вызвать веб-сервис, содержащий квадратные скобки [] . Но я не знаю, как я могу назвать этот API.
URL показан ниже http запрос метод GET.
https: "ВАШ URL" /? SearchCriteria [filter_groups][0] [фильтры] [0] [поле] = имя & searchCriteria [filter_groups] [0] [фильтры] [0] [значение] = (txtFldSearch.text!) * +1009 * & searchCriteria [filter_groups] [0] [фильтры] [0] [условие_типа] = как
это то, что я пытался
@objc func getHintsFromTextField(textField: UITextField) {
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let url = URL(string: "https:"YOUR URL"/?searchCriteria[filter_groups][0][filters][0][field]=name&searchCriteria[filter_groups][0][filters][0][value]=%\(txtFldSearch.text!)%&searchCriteria[filter_groups][0][filters][0][condition_type]=like")!
let task = session.dataTask(with: url!) { data, response, error in
// ensure there is no error for this HTTP response
guard error == nil else {
print ("error: \(error!)")
return
}
// ensure there is data returned from this HTTP response
guard let content = data else {
print("No data")
return
}
// serialise the data / NSData object into Dictionary [String : Any]
guard let json = (try? JSONSerialization.jsonObject(with: content, options: JSONSerialization.ReadingOptions.mutableContainers)) as? [String: Any] else {
print("Not containing JSON")
return
}
print("gotten json response dictionary is \n \(json)")
// update UI using the response here
}
// execute the HTTP request
task.resume()
}
Как правильно это сделать? .Помогите помочь. Я не могу назвать этот API.