I am making a url call with Alamofire to GET data as below.
In first step I convert JSON array to this format
["a", "b", "b", "c"]
and its work correctly. The question it is _price
variable is like this
["1233", "1333","3422","2422"]
But i need to remove double quotes from _price
array
and eventually _price
show like this
[1233, 1333, 3422, 2422]
class ChartVC: UIViewController {
var _year : [String] = []
var _month : [String] = []
var _price : [String] = []
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
getData()
}
func getData() {
AF.request(DOLLAR_CHART).response { (response) in
guard let data = response.data else { return }
let responseJSON = try? JSONSerialization.jsonObject(with: data, options: [])
if let items = responseJSON as? [[String: Any]] {
var years: [String] = []
var months: [String] = []
var prices: [String] = []
for item in items {
if let year = item["year"] as? String {
years.append(year)
}
if let month = item["month"] as? String {
months.append(month)
}
if let price = item["price"] as? String {
prices.append(price)
}
}
self._year = years
self._month = months
self._price = prices
print(self._price)
// show like this when print that["1233", "1333","3422","2422"]
// how to show like this [1233, 1333, 3422, 2422]
}
} else {
print("json is not array dictionary")
}
}
}