英文:
Parsing nested JSON errors
问题
我从中文翻译中提取了代码部分,并为您提供了翻译,以下是代码的翻译部分:
import UIKit
struct GETprojects: Codable {
    var projectGetResult: Bool
    var projectGetProjects: ProjectGetProjects
}
struct ProjectGetProjects: Codable {
    var projects: [Projects] = Array()
}
struct Projects: Codable {
    var id: String
    var name:  String
    var status:  String
    var category:  String
    var type:  String
    var updated:  String
    var value:  String
    var units:  String
    var address:  Address
    var contacts: Contacts
}
struct Address: Codable {
    var  erf: String
    var  street: String
    var  street2: String
    var  town: String
    var  city: String
    var  region: String
    var  postalCode: String
}
struct Contacts: Codable {
    var professional, contractor: Contact
}
struct Contact: Codable {
   var  id: String
    var  name: String
    var  company: String
    var  phone: String
    var  mobile: String
    var  email: String
    var  type: String
}
let JSONString = """
{
    "projectGetResult": true,
    "projectGetProjects": [
      {
          "id": "123-uni-que",
          "name": "Amazon",
          "status": "Planning",
          "category": "Commercial",
          "type": "Office Block",
          "updated": "21 March 2023",
          "value": 100000000,
          "units": 1,
          "address": {
              "erf": "101-RE",
              "street": "First Avenue",
              "street2": "",
              "town": "Cape Town",
              "city": "Cape Town",
              "region": "Western Cape",
              "postalCode": "111"
          },
          "contacts": {
              "professional": [
                  {
                  "id": "pr123",
                  "name":"Charles Darwin",
                  "company":"Darwin Designs",
                  "phone":"011 234 5678",
                  "mobile":"071 234 5678",
                  "email":"darwin@archi.com",
                  "type":"Architect"
                  },
                  {
                  "id": "pr234",
                  "name":"Bill Hutchins",
                  "company":"Hutchins Engineering",
                  "phone":"012 345 6789",
                  "mobile":"072 345 6789",
                  "email":"bill@engi.com",
                  "type":"Engineer"
                  },
    {
    "id": "pr345",
    "name":"Kevin Counter",
    "company":"KCQS",
    "phone":"013 456 7890",
    "mobile":"073 456 7890",
    "email":"k@county.com",
    "type":"Quantity Surveyor"
    }
    ],
    "contractor": [
    {
    "id": "con123",
    "name":"Leonardo da Vinci",
    "company":"MegaBuild",
    "phone":"014 567 8901",
    "mobile":"074 567 8901",
    "email":"leo@buildy.com",
    "type":"Main"
    },
    {
    "id": "con234",
    "name":"Steve Cleer",
                  "company":"SC Civils",
                  "phone":"015 678 9012",
                  "mobile":"075 678 9012",
                  "email":"sc@earthy.com",
                  "type":"Civil"
                  },
                  {
                      "id": "con345",
                      "name":"Warren Fright",
                      "company":"Electrified",
                      "phone":"016 789 0123",
                      "mobile":"076 789 0123",
                      "email":"@sparky.com",
                      "type":"Electrical"
                      }
              ]
          }
      },
      {
          "id": "234-uni-que",
          "name": "TBC SA",
          "status": "On Site",
          "category": "Commercial",
          "type": "Office Block",
          "updated": "21 March 2023",
          "value": 200000000,
          "units": 2,
          "address": {
              "erf": "102-RE",
              "street": "Second Avenue",
              "street2": "Corner of 4th",
              "town": "Stellenbosch",
              "city": "Cape Town",
              "region": "Western Cape",
              "postalCode": "222"
          },
          "contacts":  {
                  "professional": [
                      {
                      "id": "pr123",
                      "name":"Charles Darwin",
                      "company":"Darwin Designs",
                      "phone":"011 234 5678",
                      "mobile":"071 234 5678",
                      "email":"darwin@archi.com",
                      "type":"Architect"
                      },
                      {
                      "id": "pr234",
                      "name":"Bill Hutchins",
                      "company":"Hutchins Engineering",
                      "phone":"012 345 6789",
                      "mobile":"072 345 6789",
                      "email":"bill@engi.com",
                      "type":"Engineer"
                      },
                      {
                          "id": "pr345",
                          "name":"Kevin Counter",
                          "company":"KCQS",
                          "phone":"013 456 7890",
                          "mobile":"073 456 7890",
                          "email":"k@county.com",
                          "type":"Quantity Surveyor"
                          }
                  ],
                  "contractor": [
                      {
                      "id": "con123",
                      "name":"Leonardo da Vinci",
                      "company":"MegaBuild",
                      "phone":"014 567 8901",
                      "mobile":"074 567 8901",
                      "email":"leo@buildy.com",
                      "type":"Main"
                      },
                      {
                      "id": "con234",
                      "name":"Steve Cleer",
                      "company":"SC Civils",
                      "phone":"015 678 9012",
                      "mobile":"075 678 9012",
                      "email":"sc@earthy.com",
                      "type":"Civil"
                      },
                      {
                          "id": "con345",
                          "name":"Warren Fright",
                          "company":"Electrified",
                          "phone":"016 789 0123",
                          "mobile":"076 789 0123",
                          "email":"@sparky.com",
                          "type":"Electrical"
                          }
                  ]
              }
      },
      {
          "id": "345-uni-que",
          "name": "Rolling Stock",
          "status": "Out to Tender",
          "category": "Commercial",
          "type": "Office Block",
          "updated": "21 March 2023",
          "value": 300000000,
          "units": 3,
          "address": {
              "erf": "103-RE",
              "street": "Third Avenue",
              "street2":
<details>
<summary>英文:</summary>
I have a JSON file I am trying to extract data from and I keep getting errors that I cannot resolve for some reason, any advice?
Here is how I am running it in playgrounds
import UIKit
struct GETprojects: Codable {
var projectGetResult: Bool
var projectGetProjects: ProjectGetProjects
}
struct ProjectGetProjects: Codable {
var projects: [Projects] = Array()
}
struct Projects: Codable {
var id: String
var name:  String
var status:  String
var category:  String
var type:  String
var updated:  String
var value:  String
var units:  String
var address:  Address
var contacts: Contacts
}
struct Address: Codable {
var  erf: String
var  street: String
var  street2: String
var  town: String
var  city: String
var  region: String
var  postalCode: String
}
struct Contacts: Codable {
var professional, contractor: Contact
}
struct Contact: Codable {
var  id: String
var  name: String
var  company: String
var  phone: String
var  mobile: String
var  email: String
var  type: String
}
'''
let JSONString = """
{
"projectGetResult": true,
"projectGetProjects": [
{
"id": "123-uni-que",
"name": "Amazon",
"status": "Planning",
"category": "Commercial",
"type": "Office Block",
"updated": "21 March 2023",
"value": 100000000,
"units": 1,
"address": {
"erf": "101-RE",
"street": "First Avenue",
"street2": "",
"town": "Cape Town",
"city": "Cape Town",
"region": "Western Cape",
"postalCode": "111"
},
"contacts": {
"professional": [
{
"id": "pr123",
"name":"Charles Darwin",
"company":"Darwin Designs",
"phone":"011 234 5678",
"mobile":"071 234 5678",
"email":"darwin@archi.com",
"type":"Architect"
},
{
"id": "pr234",
"name":"Bill Hutchins",
"company":"Hutchins Engineering",
"phone":"012 345 6789",
"mobile":"072 345 6789",
"email":"bill@engi.com",
"type":"Engineer"
},
{
"id": "pr345",
"name":"Kevin Counter",
"company":"KCQS",
"phone":"013 456 7890",
"mobile":"073 456 7890",
"email":"k@county.com",
"type":"Quantity Surveyor"
}
],
"contractor": [
{
"id": "con123",
"name":"Leonardo da Vinci",
"company":"MegaBuild",
"phone":"014 567 8901",
"mobile":"074 567 8901",
"email":"leo@buildy.com",
"type":"Main"
},
{
"id": "con234",
"name":"Steve Cleer",
"company":"SC Civils",
"phone":"015 678 9012",
"mobile":"075 678 9012",
"email":"sc@earthy.com",
"type":"Civil"
},
{
"id": "con345",
"name":"Warren Fright",
"company":"Electrified",
"phone":"016 789 0123",
"mobile":"076 789 0123",
"email":"@sparky.com",
"type":"Electrical"
}
]
}
},
{
"id": "234-uni-que",
"name": "TBC SA",
"status": "On Site",
"category": "Commercial",
"type": "Office Block",
"updated": "21 March 2023",
"value": 200000000,
"units": 2,
"address": {
"erf": "102-RE",
"street": "Second Avenue",
"street2": "Corner of 4th",
"town": "Stellenbosch",
"city": "Cape Town",
"region": "Western Cape",
"postalCode": "222"
},
"contacts":  {
"professional": [
{
"id": "pr123",
"name":"Charles Darwin",
"company":"Darwin Designs",
"phone":"011 234 5678",
"mobile":"071 234 5678",
"email":"darwin@archi.com",
"type":"Architect"
},
{
"id": "pr234",
"name":"Bill Hutchins",
"company":"Hutchins Engineering",
"phone":"012 345 6789",
"mobile":"072 345 6789",
"email":"bill@engi.com",
"type":"Engineer"
},
{
"id": "pr345",
"name":"Kevin Counter",
"company":"KCQS",
"phone":"013 456 7890",
"mobile":"073 456 7890",
"email":"k@county.com",
"type":"Quantity Surveyor"
}
],
"contractor": [
{
"id": "con123",
"name":"Leonardo da Vinci",
"company":"MegaBuild",
"phone":"014 567 8901",
"mobile":"074 567 8901",
"email":"leo@buildy.com",
"type":"Main"
},
{
"id": "con234",
"name":"Steve Cleer",
"company":"SC Civils",
"phone":"015 678 9012",
"mobile":"075 678 9012",
"email":"sc@earthy.com",
"type":"Civil"
},
{
"id": "con345",
"name":"Warren Fright",
"company":"Electrified",
"phone":"016 789 0123",
"mobile":"076 789 0123",
"email":"@sparky.com",
"type":"Electrical"
}
]
}
},
{
"id": "345-uni-que",
"name": "Rolling Stock",
"status": "Out to Tender",
"category": "Commercial",
"type": "Office Block",
"updated": "21 March 2023",
"value": 300000000,
"units": 3,
"address": {
"erf": "103-RE",
"street": "Third Avenue",
"street2": "",
"town": "Swellendam",
"city": "Drakenstein",
"region": "Western Cape",
"postalCode": "333"
},
"contacts":  {
"professional": [
{
"id": "pr123",
"name":"Charles Darwin",
"company":"Darwin Designs",
"phone":"011 234 5678",
"mobile":"071 234 5678",
"email":"darwin@archi.com",
"type":"Architect"
},
{
"id": "pr234",
"name":"Bill Hutchins",
"company":"Hutchins Engineering",
"phone":"012 345 6789",
"mobile":"072 345 6789",
"email":"bill@engi.com",
"type":"Engineer"
},
{
"id": "pr345",
"name":"Kevin Counter",
"company":"KCQS",
"phone":"013 456 7890",
"mobile":"073 456 7890",
"email":"k@county.com",
"type":"Quantity Surveyor"
}
],
"contractor": [
{
"id": "con123",
"name":"Leonardo da Vinci",
"company":"MegaBuild",
"phone":"014 567 8901",
"mobile":"074 567 8901",
"email":"leo@buildy.com",
"type":"Main"
},
{
"id": "con234",
"name":"Steve Cleer",
"company":"SC Civils",
"phone":"015 678 9012",
"mobile":"075 678 9012",
"email":"sc@earthy.com",
"type":"Civil"
},
{
"id": "con345",
"name":"Warren Fright",
"company":"Electrified",
"phone":"016 789 0123",
"mobile":"076 789 0123",
"email":"@sparky.com",
"type":"Electrical"
}
]
}}]}
"""
print(JSONString)
let jsonData = JSONString.data(using: .utf8)!
do {
let decoder = JSONDecoder()
let tableData = try decoder.decode(GETprojects.self, from: jsonData)
print(tableData)
print("Rows in array: (tableData.projectGetProjects.count)")
}
catch {
print (error)
}`
getting the error: 
**Value of type 'GETprojects' has no member 'GETprojects'**
at: print("Rows in array: \(tableData.GETprojects.projectGetProjects.count)")
No matter how I configure the tableData I get a similar error, what am I missing?
</details>
# 答案1
**得分**: 0
也许你创建了错误的模型。
尝试这个模型并按照这个网站创建模型。https://app.quicktype.io/
```swift
// MARK: - GETprojects
struct GETprojects: Codable {
let projectGetResult: Bool?
let projectGetProjects: [ProjectGetProject]?
}
// MARK: - ProjectGetProject
struct ProjectGetProject: Codable {
let id, name, status, category: String?
let type, updated: String?
let value, units: Int?
let address: Address?
let contacts: Contacts?
}
// MARK: - Address
struct Address: Codable {
let erf, street, street2, town: String?
let city, region, postalCode: String?
}
// MARK: - Contacts
struct Contacts: Codable {
let professional, contractor: [Contractor]?
}
// MARK: - Contractor
struct Contractor: Codable {
let id, name, company, phone: String?
let mobile, email, type: String?
}
print(JSONString)
let jsonData = JSONString.data(using: .utf8)!
do {
    let decoder = JSONDecoder()
    let tableData = try decoder.decode(GETprojects.self, from: jsonData)
    print(tableData)
    print("数组中的行数: \(tableData.projectGetProjects?.count)")
}
catch {
    print (error)
}
英文:
Maybe you've created the wrong model.
Try this model and follow this website to create a model. https://app.quicktype.io/
// MARK: - GETprojects
struct GETprojects: Codable {
let projectGetResult: Bool?
let projectGetProjects: [ProjectGetProject]?
}
// MARK: - ProjectGetProject
struct ProjectGetProject: Codable {
let id, name, status, category: String?
let type, updated: String?
let value, units: Int?
let address: Address?
let contacts: Contacts?
}
// MARK: - Address
struct Address: Codable {
let erf, street, street2, town: String?
let city, region, postalCode: String?
}
// MARK: - Contacts
struct Contacts: Codable {
let professional, contractor: [Contractor]?
}
// MARK: - Contractor
struct Contractor: Codable {
let id, name, company, phone: String?
let mobile, email, type: String?
}
  print(JSONString)
let jsonData = JSONString.data(using: .utf8)!
do {
let decoder = JSONDecoder()
let tableData = try decoder.decode(GETprojects.self, from: jsonData)
print(tableData)
print("Rows in array: \(tableData.projectGetProjects?.count)")
}
catch {
print (error)
}
答案2
得分: 0
以下是您提供的代码的翻译部分:
struct Welcome: Codable {
    let projectGetResult: Bool
    let projectGetProjects: [ProjectGetProject]
}
struct ProjectGetProject: Codable {
    let id, name, status, category: String
    let type, updated: String
    let value, units: Int
    let address: Address
    let contacts: Contacts
}
struct Address: Codable {
    let erf, street, street2, town: String
    let city, region, postalCode: String
}
struct Contacts: Codable {
    let professional, contractor: [Contractor]
}
struct Contractor: Codable {
    let id, name, company, phone: String
    let mobile, email, type: String
}
class ViewController: UIViewController {
    
    let stringThing = """
    {
        "projectGetResult": true,
        "projectGetProjects": [
          {
              "id": "123-uni-que",
              "name": "Amazon",
              "status": "Planning",
              "category": "Commercial",
              "type": "Office Block",
              "updated": "21 March 2023",
              "value": 100000000,
              "units": 1,
              "address": {
                  "erf": "101-RE",
                  "street": "First Avenue",
                  "street2": "",
                  "town": "Cape Town",
                  "city": "Cape Town",
                  "region": "Western Cape",
                  "postalCode": "111"
              },
              "contacts": {
                  "professional": [
                      {
                      "id": "pr123",
                      "name":"Charles Darwin",
                      "company":"Darwin Designs",
                      "phone":"011 234 5678",
                      "mobile":"071 234 5678",
                      "email":"darwin@archi.com",
                      "type":"Architect"
                      },
                      {
                      "id": "pr234",
                      "name":"Bill Hutchins",
                      "company":"Hutchins Engineering",
                      "phone":"012 345 6789",
                      "mobile":"072 345 6789",
                      "email":"bill@engi.com",
                      "type":"Engineer"
                      },
        {
        "id": "pr345",
        "name":"Kevin Counter",
        "company":"KCQS",
        "phone":"013 456 7890",
        "mobile":"073 456 7890",
        "email":"k@county.com",
        "type":"Quantity Surveyor"
        }
        ],
        "contractor": [
        {
        "id": "con123",
        "name":"Leonardo da Vinci",
        "company":"MegaBuild",
        "phone":"014 567 8901",
        "mobile":"074 567 8901",
        "email":"leo@buildy.com",
        "type":"Main"
        },
        {
        "id": "con234",
        "name":"Steve Cleer",
                      "company":"SC Civils",
                      "phone":"015 678 9012",
                      "mobile":"075 678 9012",
                      "email":"sc@earthy.com",
                      "type":"Civil"
                      },
                      {
                          "id": "con345",
                          "name":"Warren Fright",
                          "company":"Electrified",
                          "phone":"016 789 0123",
                          "mobile":"076 789 0123",
                          "email":"@sparky.com",
                          "type":"Electrical"
                          }
                      ]
                  }
              }
          },
          {
              "id": "234-uni-que",
              "name": "TBC SA",
              "status": "On Site",
              "category": "Commercial",
              "type": "Office Block",
              "updated": "21 March 2023",
              "value": 200000000,
              "units": 2,
              "address": {
                  "erf": "102-RE",
                  "street": "Second Avenue",
                  "street2": "Corner of 4th",
                  "town": "Stellenbosch",
                  "city": "Cape Town",
                  "region": "Western Cape",
                  "postalCode": "222"
              },
              "contacts":  {
                      "professional": [
                          {
                          "id": "pr123",
                          "name":"Charles Darwin",
                          "company":"Darwin Designs",
                          "phone":"011 234 5678",
                          "mobile":"071 234 5678",
                          "email":"darwin@archi.com",
                          "type":"Architect"
                          },
                          {
                          "id": "pr234",
                          "name":"Bill Hutchins",
                          "company":"Hutchins Engineering",
                          "phone":"012 345 6789",
                          "mobile":"072 345 6789",
                          "email":"bill@engi.com",
                          "type":"Engineer"
                          },
                          {
                              "id": "pr345",
                              "name":"Kevin Counter",
                              "company":"KCQS",
                              "phone":"013 456 7890",
                              "mobile":"073 456 7890",
                              "email":"k@county.com",
                              "type":"Quantity Surveyor"
                              }
                      ],
                      "contractor": [
                          {
                          "id": "con123",
                          "name":"Leonardo da Vinci",
                          "company":"MegaBuild",
                          "phone":"014 567 8901",
                          "mobile":"074 567 8901",
                          "email":"leo@buildy.com",
                          "type":"Main"
                          },
                          {
                          "id": "con234",
                          "name":"Steve Cleer",
                          "company":"SC Civils",
                          "phone":"015 678 9012",
                          "mobile":"075 678 9012",
                          "email":"sc@earthy.com",
                          "type":"Civil"
                          },
                          {
                              "id": "con345",
                              "name":"Warren Fright",
                              "company":"Electrified",
                              "phone":"016 789 0123",
                              "mobile":"076 789 0123",
                              "email":"@sparky.com",
                              "type":"Electrical"
                              }
                      ]
                  }
          },
          {
              "id": "345-uni-que",
              "name": "Rolling Stock",
              "status": "Out to Tender",
              "category": "Commercial",
              "type": "Office Block",
              "updated": "21 March 2023",
              "value": 300000000,
              "units": 3,
              "address": {
                  "erf": "103-RE",
                  "street": "Third Avenue",
                  "street2": "",
                  "town": "Swellendam",
                  "city": "Drakenstein",
                  "region": "Western Cape",
                  "postalCode": "333"
              },
              "contacts":  {
                      "professional": [
                          {
                          "id": "pr123",
                          "name":"Charles Darwin",
                          "company":"Darwin Designs",
                          "phone":"011 234 5678",
                          "mobile":"071 234 5678",
                          "email":"darwin@archi.com",
                          "type":"Architect"
<details>
<summary>英文:</summary>
    struct Welcome: Codable {
        let projectGetResult: Bool
        let projectGetProjects: [ProjectGetProject]
    }
    
    struct ProjectGetProject: Codable {
        let id, name, status, category: String
        let type, updated: String
        let value, units: Int
        let address: Address
        let contacts: Contacts
    }
    
    struct Address: Codable {
        let erf, street, street2, town: String
        let city, region, postalCode: String
    }
    
    struct Contacts: Codable {
        let professional, contractor: [Contractor]
    }
    
    struct Contractor: Codable {
        let id, name, company, phone: String
        let mobile, email, type: String
    }
    
    
    class ViewController: UIViewController {
        
        let stringThing = """
        {
            "projectGetResult": true,
            "projectGetProjects": [
              {
                  "id": "123-uni-que",
                  "name": "Amazon",
                  "status": "Planning",
                  "category": "Commercial",
                  "type": "Office Block",
                  "updated": "21 March 2023",
                  "value": 100000000,
                  "units": 1,
                  "address": {
                      "erf": "101-RE",
                      "street": "First Avenue",
                      "street2": "",
                      "town": "Cape Town",
                      "city": "Cape Town",
                      "region": "Western Cape",
                      "postalCode": "111"
                  },
                  "contacts": {
                      "professional": [
                          {
                          "id": "pr123",
                          "name":"Charles Darwin",
                          "company":"Darwin Designs",
                          "phone":"011 234 5678",
                          "mobile":"071 234 5678",
                          "email":"darwin@archi.com",
                          "type":"Architect"
                          },
                          {
                          "id": "pr234",
                          "name":"Bill Hutchins",
                          "company":"Hutchins Engineering",
                          "phone":"012 345 6789",
                          "mobile":"072 345 6789",
                          "email":"bill@engi.com",
                          "type":"Engineer"
                          },
            {
            "id": "pr345",
            "name":"Kevin Counter",
            "company":"KCQS",
            "phone":"013 456 7890",
            "mobile":"073 456 7890",
            "email":"k@county.com",
            "type":"Quantity Surveyor"
            }
            ],
            "contractor": [
            {
            "id": "con123",
            "name":"Leonardo da Vinci",
            "company":"MegaBuild",
            "phone":"014 567 8901",
            "mobile":"074 567 8901",
            "email":"leo@buildy.com",
            "type":"Main"
            },
            {
            "id": "con234",
            "name":"Steve Cleer",
                          "company":"SC Civils",
                          "phone":"015 678 9012",
                          "mobile":"075 678 9012",
                          "email":"sc@earthy.com",
                          "type":"Civil"
                          },
                          {
                              "id": "con345",
                              "name":"Warren Fright",
                              "company":"Electrified",
                              "phone":"016 789 0123",
                              "mobile":"076 789 0123",
                              "email":"@sparky.com",
                              "type":"Electrical"
                              }
                      ]
                  }
              },
              {
                  "id": "234-uni-que",
                  "name": "TBC SA",
                  "status": "On Site",
                  "category": "Commercial",
                  "type": "Office Block",
                  "updated": "21 March 2023",
                  "value": 200000000,
                  "units": 2,
                  "address": {
                      "erf": "102-RE",
                      "street": "Second Avenue",
                      "street2": "Corner of 4th",
                      "town": "Stellenbosch",
                      "city": "Cape Town",
                      "region": "Western Cape",
                      "postalCode": "222"
                  },
                  "contacts":  {
                          "professional": [
                              {
                              "id": "pr123",
                              "name":"Charles Darwin",
                              "company":"Darwin Designs",
                              "phone":"011 234 5678",
                              "mobile":"071 234 5678",
                              "email":"darwin@archi.com",
                              "type":"Architect"
                              },
                              {
                              "id": "pr234",
                              "name":"Bill Hutchins",
                              "company":"Hutchins Engineering",
                              "phone":"012 345 6789",
                              "mobile":"072 345 6789",
                              "email":"bill@engi.com",
                              "type":"Engineer"
                              },
                              {
                                  "id": "pr345",
                                  "name":"Kevin Counter",
                                  "company":"KCQS",
                                  "phone":"013 456 7890",
                                  "mobile":"073 456 7890",
                                  "email":"k@county.com",
                                  "type":"Quantity Surveyor"
                                  }
                          ],
                          "contractor": [
                              {
                              "id": "con123",
                              "name":"Leonardo da Vinci",
                              "company":"MegaBuild",
                              "phone":"014 567 8901",
                              "mobile":"074 567 8901",
                              "email":"leo@buildy.com",
                              "type":"Main"
                              },
                              {
                              "id": "con234",
                              "name":"Steve Cleer",
                              "company":"SC Civils",
                              "phone":"015 678 9012",
                              "mobile":"075 678 9012",
                              "email":"sc@earthy.com",
                              "type":"Civil"
                              },
                              {
                                  "id": "con345",
                                  "name":"Warren Fright",
                                  "company":"Electrified",
                                  "phone":"016 789 0123",
                                  "mobile":"076 789 0123",
                                  "email":"@sparky.com",
                                  "type":"Electrical"
                                  }
                          ]
                      }
              },
              {
                  "id": "345-uni-que",
                  "name": "Rolling Stock",
                  "status": "Out to Tender",
                  "category": "Commercial",
                  "type": "Office Block",
                  "updated": "21 March 2023",
                  "value": 300000000,
                  "units": 3,
                  "address": {
                      "erf": "103-RE",
                      "street": "Third Avenue",
                      "street2": "",
                      "town": "Swellendam",
                      "city": "Drakenstein",
                      "region": "Western Cape",
                      "postalCode": "333"
                  },
                  "contacts":  {
                          "professional": [
                              {
                              "id": "pr123",
                              "name":"Charles Darwin",
                              "company":"Darwin Designs",
                              "phone":"011 234 5678",
                              "mobile":"071 234 5678",
                              "email":"darwin@archi.com",
                              "type":"Architect"
                              },
                              {
                              "id": "pr234",
                              "name":"Bill Hutchins",
                              "company":"Hutchins Engineering",
                              "phone":"012 345 6789",
                              "mobile":"072 345 6789",
                              "email":"bill@engi.com",
                              "type":"Engineer"
                              },
            {
            "id": "pr345",
            "name":"Kevin Counter",
            "company":"KCQS",
            "phone":"013 456 7890",
            "mobile":"073 456 7890",
            "email":"k@county.com",
            "type":"Quantity Surveyor"
            }
            ],
            "contractor": [
            {
            "id": "con123",
            "name":"Leonardo da Vinci",
            "company":"MegaBuild",
            "phone":"014 567 8901",
            "mobile":"074 567 8901",
            "email":"leo@buildy.com",
            "type":"Main"
            },
            {
            "id": "con234",
            "name":"Steve Cleer",
            "company":"SC Civils",
            "phone":"015 678 9012",
            "mobile":"075 678 9012",
            "email":"sc@earthy.com",
            "type":"Civil"
            },
            {
            "id": "con345",
            "name":"Warren Fright",
            "company":"Electrified",
            "phone":"016 789 0123",
            "mobile":"076 789 0123",
            "email":"@sparky.com",
            "type":"Electrical"
            }
            ]
            }}]}
        """
        
        override func viewDidLoad() {
            super.viewDidLoad()
            
            do{
                let jsonData = stringThing.data(using: .utf8)!
                let result = try JSONDecoder().decode(Welcome.self, from: jsonData)
                print(result)
            }catch{
                print("error")
            }
        }
    }
</details>
				通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论