Skip to main content


Showing posts with the label Parse JSON Data(GET Method)

Parse JSON Data with GET Method Using JsonDecoder in iOS

Parse JSON Data(GET Method) in UITableViewCell Using JsonDecoder Swift 4 & Xcode 9

1) -- ViewController Class
First Create a new Project (ParseDataGETMethod) after make a struct (GetJsonData) type data parameter

import UIKit
struct GetJsonData:Decodable { let name: String let capital: String let alpha2Code: String let alpha3Code: String let region: String let subregion: String } class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var arrData = [GetJsonData]() @IBOutletvar tableView: UITableView! overridefunc viewDidLoad() { super.viewDidLoad() getJSONData() } func getJSONData(){ let url = URL(string: "") let session = URLSession.shared session.dataTask(with: url!) { (data, response, error) in do{ if error == nil { self.arrData = tryJSONDecoder().decode([GetJsonData].self, from: data!) formainarr inself.arrData{ // print(, ":",, "-", mainarr.alpha2Code ) DispatchQueue.main.sync { s…