解析嵌套的JSON错误

huangapple go评论64阅读模式
英文:

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 &#39;GETprojects&#39; has no member &#39;GETprojects&#39;**
at: print(&quot;Rows in array: \(tableData.GETprojects.projectGetProjects.count)&quot;)
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(&quot;Rows in array: \(tableData.projectGetProjects?.count)&quot;)
}
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 = &quot;&quot;&quot;
        {
            &quot;projectGetResult&quot;: true,
            &quot;projectGetProjects&quot;: [
              {
                  &quot;id&quot;: &quot;123-uni-que&quot;,
                  &quot;name&quot;: &quot;Amazon&quot;,
                  &quot;status&quot;: &quot;Planning&quot;,
                  &quot;category&quot;: &quot;Commercial&quot;,
                  &quot;type&quot;: &quot;Office Block&quot;,
                  &quot;updated&quot;: &quot;21 March 2023&quot;,
                  &quot;value&quot;: 100000000,
                  &quot;units&quot;: 1,
                  &quot;address&quot;: {
                      &quot;erf&quot;: &quot;101-RE&quot;,
                      &quot;street&quot;: &quot;First Avenue&quot;,
                      &quot;street2&quot;: &quot;&quot;,
                      &quot;town&quot;: &quot;Cape Town&quot;,
                      &quot;city&quot;: &quot;Cape Town&quot;,
                      &quot;region&quot;: &quot;Western Cape&quot;,
                      &quot;postalCode&quot;: &quot;111&quot;
                  },
                  &quot;contacts&quot;: {
                      &quot;professional&quot;: [
                          {
                          &quot;id&quot;: &quot;pr123&quot;,
                          &quot;name&quot;:&quot;Charles Darwin&quot;,
                          &quot;company&quot;:&quot;Darwin Designs&quot;,
                          &quot;phone&quot;:&quot;011 234 5678&quot;,
                          &quot;mobile&quot;:&quot;071 234 5678&quot;,
                          &quot;email&quot;:&quot;darwin@archi.com&quot;,
                          &quot;type&quot;:&quot;Architect&quot;
                          },
                          {
                          &quot;id&quot;: &quot;pr234&quot;,
                          &quot;name&quot;:&quot;Bill Hutchins&quot;,
                          &quot;company&quot;:&quot;Hutchins Engineering&quot;,
                          &quot;phone&quot;:&quot;012 345 6789&quot;,
                          &quot;mobile&quot;:&quot;072 345 6789&quot;,
                          &quot;email&quot;:&quot;bill@engi.com&quot;,
                          &quot;type&quot;:&quot;Engineer&quot;
                          },
            {
            &quot;id&quot;: &quot;pr345&quot;,
            &quot;name&quot;:&quot;Kevin Counter&quot;,
            &quot;company&quot;:&quot;KCQS&quot;,
            &quot;phone&quot;:&quot;013 456 7890&quot;,
            &quot;mobile&quot;:&quot;073 456 7890&quot;,
            &quot;email&quot;:&quot;k@county.com&quot;,
            &quot;type&quot;:&quot;Quantity Surveyor&quot;
            }
            ],
            &quot;contractor&quot;: [
            {
            &quot;id&quot;: &quot;con123&quot;,
            &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
            &quot;company&quot;:&quot;MegaBuild&quot;,
            &quot;phone&quot;:&quot;014 567 8901&quot;,
            &quot;mobile&quot;:&quot;074 567 8901&quot;,
            &quot;email&quot;:&quot;leo@buildy.com&quot;,
            &quot;type&quot;:&quot;Main&quot;
            },
            {
            &quot;id&quot;: &quot;con234&quot;,
            &quot;name&quot;:&quot;Steve Cleer&quot;,
                          &quot;company&quot;:&quot;SC Civils&quot;,
                          &quot;phone&quot;:&quot;015 678 9012&quot;,
                          &quot;mobile&quot;:&quot;075 678 9012&quot;,
                          &quot;email&quot;:&quot;sc@earthy.com&quot;,
                          &quot;type&quot;:&quot;Civil&quot;
                          },
                          {
                              &quot;id&quot;: &quot;con345&quot;,
                              &quot;name&quot;:&quot;Warren Fright&quot;,
                              &quot;company&quot;:&quot;Electrified&quot;,
                              &quot;phone&quot;:&quot;016 789 0123&quot;,
                              &quot;mobile&quot;:&quot;076 789 0123&quot;,
                              &quot;email&quot;:&quot;@sparky.com&quot;,
                              &quot;type&quot;:&quot;Electrical&quot;
                              }
                      ]
                  }
              },
              {
                  &quot;id&quot;: &quot;234-uni-que&quot;,
                  &quot;name&quot;: &quot;TBC SA&quot;,
                  &quot;status&quot;: &quot;On Site&quot;,
                  &quot;category&quot;: &quot;Commercial&quot;,
                  &quot;type&quot;: &quot;Office Block&quot;,
                  &quot;updated&quot;: &quot;21 March 2023&quot;,
                  &quot;value&quot;: 200000000,
                  &quot;units&quot;: 2,
                  &quot;address&quot;: {
                      &quot;erf&quot;: &quot;102-RE&quot;,
                      &quot;street&quot;: &quot;Second Avenue&quot;,
                      &quot;street2&quot;: &quot;Corner of 4th&quot;,
                      &quot;town&quot;: &quot;Stellenbosch&quot;,
                      &quot;city&quot;: &quot;Cape Town&quot;,
                      &quot;region&quot;: &quot;Western Cape&quot;,
                      &quot;postalCode&quot;: &quot;222&quot;
                  },
                  &quot;contacts&quot;:  {
                          &quot;professional&quot;: [
                              {
                              &quot;id&quot;: &quot;pr123&quot;,
                              &quot;name&quot;:&quot;Charles Darwin&quot;,
                              &quot;company&quot;:&quot;Darwin Designs&quot;,
                              &quot;phone&quot;:&quot;011 234 5678&quot;,
                              &quot;mobile&quot;:&quot;071 234 5678&quot;,
                              &quot;email&quot;:&quot;darwin@archi.com&quot;,
                              &quot;type&quot;:&quot;Architect&quot;
                              },
                              {
                              &quot;id&quot;: &quot;pr234&quot;,
                              &quot;name&quot;:&quot;Bill Hutchins&quot;,
                              &quot;company&quot;:&quot;Hutchins Engineering&quot;,
                              &quot;phone&quot;:&quot;012 345 6789&quot;,
                              &quot;mobile&quot;:&quot;072 345 6789&quot;,
                              &quot;email&quot;:&quot;bill@engi.com&quot;,
                              &quot;type&quot;:&quot;Engineer&quot;
                              },
                              {
                                  &quot;id&quot;: &quot;pr345&quot;,
                                  &quot;name&quot;:&quot;Kevin Counter&quot;,
                                  &quot;company&quot;:&quot;KCQS&quot;,
                                  &quot;phone&quot;:&quot;013 456 7890&quot;,
                                  &quot;mobile&quot;:&quot;073 456 7890&quot;,
                                  &quot;email&quot;:&quot;k@county.com&quot;,
                                  &quot;type&quot;:&quot;Quantity Surveyor&quot;
                                  }
                          ],
                          &quot;contractor&quot;: [
                              {
                              &quot;id&quot;: &quot;con123&quot;,
                              &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
                              &quot;company&quot;:&quot;MegaBuild&quot;,
                              &quot;phone&quot;:&quot;014 567 8901&quot;,
                              &quot;mobile&quot;:&quot;074 567 8901&quot;,
                              &quot;email&quot;:&quot;leo@buildy.com&quot;,
                              &quot;type&quot;:&quot;Main&quot;
                              },
                              {
                              &quot;id&quot;: &quot;con234&quot;,
                              &quot;name&quot;:&quot;Steve Cleer&quot;,
                              &quot;company&quot;:&quot;SC Civils&quot;,
                              &quot;phone&quot;:&quot;015 678 9012&quot;,
                              &quot;mobile&quot;:&quot;075 678 9012&quot;,
                              &quot;email&quot;:&quot;sc@earthy.com&quot;,
                              &quot;type&quot;:&quot;Civil&quot;
                              },
                              {
                                  &quot;id&quot;: &quot;con345&quot;,
                                  &quot;name&quot;:&quot;Warren Fright&quot;,
                                  &quot;company&quot;:&quot;Electrified&quot;,
                                  &quot;phone&quot;:&quot;016 789 0123&quot;,
                                  &quot;mobile&quot;:&quot;076 789 0123&quot;,
                                  &quot;email&quot;:&quot;@sparky.com&quot;,
                                  &quot;type&quot;:&quot;Electrical&quot;
                                  }
                          ]
                      }
              },
              {
                  &quot;id&quot;: &quot;345-uni-que&quot;,
                  &quot;name&quot;: &quot;Rolling Stock&quot;,
                  &quot;status&quot;: &quot;Out to Tender&quot;,
                  &quot;category&quot;: &quot;Commercial&quot;,
                  &quot;type&quot;: &quot;Office Block&quot;,
                  &quot;updated&quot;: &quot;21 March 2023&quot;,
                  &quot;value&quot;: 300000000,
                  &quot;units&quot;: 3,
                  &quot;address&quot;: {
                      &quot;erf&quot;: &quot;103-RE&quot;,
                      &quot;street&quot;: &quot;Third Avenue&quot;,
                      &quot;street2&quot;: &quot;&quot;,
                      &quot;town&quot;: &quot;Swellendam&quot;,
                      &quot;city&quot;: &quot;Drakenstein&quot;,
                      &quot;region&quot;: &quot;Western Cape&quot;,
                      &quot;postalCode&quot;: &quot;333&quot;
                  },
                  &quot;contacts&quot;:  {
                          &quot;professional&quot;: [
                              {
                              &quot;id&quot;: &quot;pr123&quot;,
                              &quot;name&quot;:&quot;Charles Darwin&quot;,
                              &quot;company&quot;:&quot;Darwin Designs&quot;,
                              &quot;phone&quot;:&quot;011 234 5678&quot;,
                              &quot;mobile&quot;:&quot;071 234 5678&quot;,
                              &quot;email&quot;:&quot;darwin@archi.com&quot;,
                              &quot;type&quot;:&quot;Architect&quot;
                              },
                              {
                              &quot;id&quot;: &quot;pr234&quot;,
                              &quot;name&quot;:&quot;Bill Hutchins&quot;,
                              &quot;company&quot;:&quot;Hutchins Engineering&quot;,
                              &quot;phone&quot;:&quot;012 345 6789&quot;,
                              &quot;mobile&quot;:&quot;072 345 6789&quot;,
                              &quot;email&quot;:&quot;bill@engi.com&quot;,
                              &quot;type&quot;:&quot;Engineer&quot;
                              },
            {
            &quot;id&quot;: &quot;pr345&quot;,
            &quot;name&quot;:&quot;Kevin Counter&quot;,
            &quot;company&quot;:&quot;KCQS&quot;,
            &quot;phone&quot;:&quot;013 456 7890&quot;,
            &quot;mobile&quot;:&quot;073 456 7890&quot;,
            &quot;email&quot;:&quot;k@county.com&quot;,
            &quot;type&quot;:&quot;Quantity Surveyor&quot;
            }
            ],
            &quot;contractor&quot;: [
            {
            &quot;id&quot;: &quot;con123&quot;,
            &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
            &quot;company&quot;:&quot;MegaBuild&quot;,
            &quot;phone&quot;:&quot;014 567 8901&quot;,
            &quot;mobile&quot;:&quot;074 567 8901&quot;,
            &quot;email&quot;:&quot;leo@buildy.com&quot;,
            &quot;type&quot;:&quot;Main&quot;
            },
            {
            &quot;id&quot;: &quot;con234&quot;,
            &quot;name&quot;:&quot;Steve Cleer&quot;,
            &quot;company&quot;:&quot;SC Civils&quot;,
            &quot;phone&quot;:&quot;015 678 9012&quot;,
            &quot;mobile&quot;:&quot;075 678 9012&quot;,
            &quot;email&quot;:&quot;sc@earthy.com&quot;,
            &quot;type&quot;:&quot;Civil&quot;
            },
            {
            &quot;id&quot;: &quot;con345&quot;,
            &quot;name&quot;:&quot;Warren Fright&quot;,
            &quot;company&quot;:&quot;Electrified&quot;,
            &quot;phone&quot;:&quot;016 789 0123&quot;,
            &quot;mobile&quot;:&quot;076 789 0123&quot;,
            &quot;email&quot;:&quot;@sparky.com&quot;,
            &quot;type&quot;:&quot;Electrical&quot;
            }
            ]
            }}]}
        &quot;&quot;&quot;
        
        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(&quot;error&quot;)
            }
        }
    }

</details>



huangapple
  • 本文由 发表于 2023年3月3日 19:02:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定