Posts

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

Parse JSON Data with GET Method Using JsonDecoder in iOS

Image
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: "https://restcountries.eu/rest/v2/all") 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.name, ":", mainarr.capital, "-", mainarr.alpha2Code ) DispatchQueue.main.sync { s…

Field Service Software

Field Service Software
Field Force Tracker