解析嵌套的JSON错误

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

Parsing nested JSON errors

问题

我从中文翻译中提取了代码部分,并为您提供了翻译,以下是代码的翻译部分:

  1. import UIKit
  2. struct GETprojects: Codable {
  3. var projectGetResult: Bool
  4. var projectGetProjects: ProjectGetProjects
  5. }
  6. struct ProjectGetProjects: Codable {
  7. var projects: [Projects] = Array()
  8. }
  9. struct Projects: Codable {
  10. var id: String
  11. var name: String
  12. var status: String
  13. var category: String
  14. var type: String
  15. var updated: String
  16. var value: String
  17. var units: String
  18. var address: Address
  19. var contacts: Contacts
  20. }
  21. struct Address: Codable {
  22. var erf: String
  23. var street: String
  24. var street2: String
  25. var town: String
  26. var city: String
  27. var region: String
  28. var postalCode: String
  29. }
  30. struct Contacts: Codable {
  31. var professional, contractor: Contact
  32. }
  33. struct Contact: Codable {
  34. var id: String
  35. var name: String
  36. var company: String
  37. var phone: String
  38. var mobile: String
  39. var email: String
  40. var type: String
  41. }
  42. let JSONString = """
  43. {
  44. "projectGetResult": true,
  45. "projectGetProjects": [
  46. {
  47. "id": "123-uni-que",
  48. "name": "Amazon",
  49. "status": "Planning",
  50. "category": "Commercial",
  51. "type": "Office Block",
  52. "updated": "21 March 2023",
  53. "value": 100000000,
  54. "units": 1,
  55. "address": {
  56. "erf": "101-RE",
  57. "street": "First Avenue",
  58. "street2": "",
  59. "town": "Cape Town",
  60. "city": "Cape Town",
  61. "region": "Western Cape",
  62. "postalCode": "111"
  63. },
  64. "contacts": {
  65. "professional": [
  66. {
  67. "id": "pr123",
  68. "name":"Charles Darwin",
  69. "company":"Darwin Designs",
  70. "phone":"011 234 5678",
  71. "mobile":"071 234 5678",
  72. "email":"darwin@archi.com",
  73. "type":"Architect"
  74. },
  75. {
  76. "id": "pr234",
  77. "name":"Bill Hutchins",
  78. "company":"Hutchins Engineering",
  79. "phone":"012 345 6789",
  80. "mobile":"072 345 6789",
  81. "email":"bill@engi.com",
  82. "type":"Engineer"
  83. },
  84. {
  85. "id": "pr345",
  86. "name":"Kevin Counter",
  87. "company":"KCQS",
  88. "phone":"013 456 7890",
  89. "mobile":"073 456 7890",
  90. "email":"k@county.com",
  91. "type":"Quantity Surveyor"
  92. }
  93. ],
  94. "contractor": [
  95. {
  96. "id": "con123",
  97. "name":"Leonardo da Vinci",
  98. "company":"MegaBuild",
  99. "phone":"014 567 8901",
  100. "mobile":"074 567 8901",
  101. "email":"leo@buildy.com",
  102. "type":"Main"
  103. },
  104. {
  105. "id": "con234",
  106. "name":"Steve Cleer",
  107. "company":"SC Civils",
  108. "phone":"015 678 9012",
  109. "mobile":"075 678 9012",
  110. "email":"sc@earthy.com",
  111. "type":"Civil"
  112. },
  113. {
  114. "id": "con345",
  115. "name":"Warren Fright",
  116. "company":"Electrified",
  117. "phone":"016 789 0123",
  118. "mobile":"076 789 0123",
  119. "email":"@sparky.com",
  120. "type":"Electrical"
  121. }
  122. ]
  123. }
  124. },
  125. {
  126. "id": "234-uni-que",
  127. "name": "TBC SA",
  128. "status": "On Site",
  129. "category": "Commercial",
  130. "type": "Office Block",
  131. "updated": "21 March 2023",
  132. "value": 200000000,
  133. "units": 2,
  134. "address": {
  135. "erf": "102-RE",
  136. "street": "Second Avenue",
  137. "street2": "Corner of 4th",
  138. "town": "Stellenbosch",
  139. "city": "Cape Town",
  140. "region": "Western Cape",
  141. "postalCode": "222"
  142. },
  143. "contacts": {
  144. "professional": [
  145. {
  146. "id": "pr123",
  147. "name":"Charles Darwin",
  148. "company":"Darwin Designs",
  149. "phone":"011 234 5678",
  150. "mobile":"071 234 5678",
  151. "email":"darwin@archi.com",
  152. "type":"Architect"
  153. },
  154. {
  155. "id": "pr234",
  156. "name":"Bill Hutchins",
  157. "company":"Hutchins Engineering",
  158. "phone":"012 345 6789",
  159. "mobile":"072 345 6789",
  160. "email":"bill@engi.com",
  161. "type":"Engineer"
  162. },
  163. {
  164. "id": "pr345",
  165. "name":"Kevin Counter",
  166. "company":"KCQS",
  167. "phone":"013 456 7890",
  168. "mobile":"073 456 7890",
  169. "email":"k@county.com",
  170. "type":"Quantity Surveyor"
  171. }
  172. ],
  173. "contractor": [
  174. {
  175. "id": "con123",
  176. "name":"Leonardo da Vinci",
  177. "company":"MegaBuild",
  178. "phone":"014 567 8901",
  179. "mobile":"074 567 8901",
  180. "email":"leo@buildy.com",
  181. "type":"Main"
  182. },
  183. {
  184. "id": "con234",
  185. "name":"Steve Cleer",
  186. "company":"SC Civils",
  187. "phone":"015 678 9012",
  188. "mobile":"075 678 9012",
  189. "email":"sc@earthy.com",
  190. "type":"Civil"
  191. },
  192. {
  193. "id": "con345",
  194. "name":"Warren Fright",
  195. "company":"Electrified",
  196. "phone":"016 789 0123",
  197. "mobile":"076 789 0123",
  198. "email":"@sparky.com",
  199. "type":"Electrical"
  200. }
  201. ]
  202. }
  203. },
  204. {
  205. "id": "345-uni-que",
  206. "name": "Rolling Stock",
  207. "status": "Out to Tender",
  208. "category": "Commercial",
  209. "type": "Office Block",
  210. "updated": "21 March 2023",
  211. "value": 300000000,
  212. "units": 3,
  213. "address": {
  214. "erf": "103-RE",
  215. "street": "Third Avenue",
  216. "street2":
  217. <details>
  218. <summary>英文:</summary>
  219. 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?
  220. 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)
}`

  1. getting the error:
  2. **Value of type &#39;GETprojects&#39; has no member &#39;GETprojects&#39;**
  3. at: print(&quot;Rows in array: \(tableData.GETprojects.projectGetProjects.count)&quot;)
  4. No matter how I configure the tableData I get a similar error, what am I missing?
  5. </details>
  6. # 答案1
  7. **得分**: 0
  8. 也许你创建了错误的模型。
  9. 尝试这个模型并按照这个网站创建模型。https://app.quicktype.io/
  10. ```swift
  11. // MARK: - GETprojects
  12. struct GETprojects: Codable {
  13. let projectGetResult: Bool?
  14. let projectGetProjects: [ProjectGetProject]?
  15. }
  16. // MARK: - ProjectGetProject
  17. struct ProjectGetProject: Codable {
  18. let id, name, status, category: String?
  19. let type, updated: String?
  20. let value, units: Int?
  21. let address: Address?
  22. let contacts: Contacts?
  23. }
  24. // MARK: - Address
  25. struct Address: Codable {
  26. let erf, street, street2, town: String?
  27. let city, region, postalCode: String?
  28. }
  29. // MARK: - Contacts
  30. struct Contacts: Codable {
  31. let professional, contractor: [Contractor]?
  32. }
  33. // MARK: - Contractor
  34. struct Contractor: Codable {
  35. let id, name, company, phone: String?
  36. let mobile, email, type: String?
  37. }
  1. print(JSONString)
  2. let jsonData = JSONString.data(using: .utf8)!
  3. do {
  4. let decoder = JSONDecoder()
  5. let tableData = try decoder.decode(GETprojects.self, from: jsonData)
  6. print(tableData)
  7. print("数组中的行数: \(tableData.projectGetProjects?.count)")
  8. }
  9. catch {
  10. print (error)
  11. }
英文:

Maybe you've created the wrong model.
Try this model and follow this website to create a model. https://app.quicktype.io/

  1. // MARK: - GETprojects
  2. struct GETprojects: Codable {
  3. let projectGetResult: Bool?
  4. let projectGetProjects: [ProjectGetProject]?
  5. }
  6. // MARK: - ProjectGetProject
  7. struct ProjectGetProject: Codable {
  8. let id, name, status, category: String?
  9. let type, updated: String?
  10. let value, units: Int?
  11. let address: Address?
  12. let contacts: Contacts?
  13. }
  14. // MARK: - Address
  15. struct Address: Codable {
  16. let erf, street, street2, town: String?
  17. let city, region, postalCode: String?
  18. }
  19. // MARK: - Contacts
  20. struct Contacts: Codable {
  21. let professional, contractor: [Contractor]?
  22. }
  23. // MARK: - Contractor
  24. struct Contractor: Codable {
  25. let id, name, company, phone: String?
  26. let mobile, email, type: String?
  27. }
  1. print(JSONString)
  2. let jsonData = JSONString.data(using: .utf8)!
  3. do {
  4. let decoder = JSONDecoder()
  5. let tableData = try decoder.decode(GETprojects.self, from: jsonData)
  6. print(tableData)
  7. print(&quot;Rows in array: \(tableData.projectGetProjects?.count)&quot;)
  8. }
  9. catch {
  10. print (error)
  11. }

答案2

得分: 0

以下是您提供的代码的翻译部分:

  1. struct Welcome: Codable {
  2. let projectGetResult: Bool
  3. let projectGetProjects: [ProjectGetProject]
  4. }
  5. struct ProjectGetProject: Codable {
  6. let id, name, status, category: String
  7. let type, updated: String
  8. let value, units: Int
  9. let address: Address
  10. let contacts: Contacts
  11. }
  12. struct Address: Codable {
  13. let erf, street, street2, town: String
  14. let city, region, postalCode: String
  15. }
  16. struct Contacts: Codable {
  17. let professional, contractor: [Contractor]
  18. }
  19. struct Contractor: Codable {
  20. let id, name, company, phone: String
  21. let mobile, email, type: String
  22. }
  23. class ViewController: UIViewController {
  24. let stringThing = """
  25. {
  26. "projectGetResult": true,
  27. "projectGetProjects": [
  28. {
  29. "id": "123-uni-que",
  30. "name": "Amazon",
  31. "status": "Planning",
  32. "category": "Commercial",
  33. "type": "Office Block",
  34. "updated": "21 March 2023",
  35. "value": 100000000,
  36. "units": 1,
  37. "address": {
  38. "erf": "101-RE",
  39. "street": "First Avenue",
  40. "street2": "",
  41. "town": "Cape Town",
  42. "city": "Cape Town",
  43. "region": "Western Cape",
  44. "postalCode": "111"
  45. },
  46. "contacts": {
  47. "professional": [
  48. {
  49. "id": "pr123",
  50. "name":"Charles Darwin",
  51. "company":"Darwin Designs",
  52. "phone":"011 234 5678",
  53. "mobile":"071 234 5678",
  54. "email":"darwin@archi.com",
  55. "type":"Architect"
  56. },
  57. {
  58. "id": "pr234",
  59. "name":"Bill Hutchins",
  60. "company":"Hutchins Engineering",
  61. "phone":"012 345 6789",
  62. "mobile":"072 345 6789",
  63. "email":"bill@engi.com",
  64. "type":"Engineer"
  65. },
  66. {
  67. "id": "pr345",
  68. "name":"Kevin Counter",
  69. "company":"KCQS",
  70. "phone":"013 456 7890",
  71. "mobile":"073 456 7890",
  72. "email":"k@county.com",
  73. "type":"Quantity Surveyor"
  74. }
  75. ],
  76. "contractor": [
  77. {
  78. "id": "con123",
  79. "name":"Leonardo da Vinci",
  80. "company":"MegaBuild",
  81. "phone":"014 567 8901",
  82. "mobile":"074 567 8901",
  83. "email":"leo@buildy.com",
  84. "type":"Main"
  85. },
  86. {
  87. "id": "con234",
  88. "name":"Steve Cleer",
  89. "company":"SC Civils",
  90. "phone":"015 678 9012",
  91. "mobile":"075 678 9012",
  92. "email":"sc@earthy.com",
  93. "type":"Civil"
  94. },
  95. {
  96. "id": "con345",
  97. "name":"Warren Fright",
  98. "company":"Electrified",
  99. "phone":"016 789 0123",
  100. "mobile":"076 789 0123",
  101. "email":"@sparky.com",
  102. "type":"Electrical"
  103. }
  104. ]
  105. }
  106. }
  107. },
  108. {
  109. "id": "234-uni-que",
  110. "name": "TBC SA",
  111. "status": "On Site",
  112. "category": "Commercial",
  113. "type": "Office Block",
  114. "updated": "21 March 2023",
  115. "value": 200000000,
  116. "units": 2,
  117. "address": {
  118. "erf": "102-RE",
  119. "street": "Second Avenue",
  120. "street2": "Corner of 4th",
  121. "town": "Stellenbosch",
  122. "city": "Cape Town",
  123. "region": "Western Cape",
  124. "postalCode": "222"
  125. },
  126. "contacts": {
  127. "professional": [
  128. {
  129. "id": "pr123",
  130. "name":"Charles Darwin",
  131. "company":"Darwin Designs",
  132. "phone":"011 234 5678",
  133. "mobile":"071 234 5678",
  134. "email":"darwin@archi.com",
  135. "type":"Architect"
  136. },
  137. {
  138. "id": "pr234",
  139. "name":"Bill Hutchins",
  140. "company":"Hutchins Engineering",
  141. "phone":"012 345 6789",
  142. "mobile":"072 345 6789",
  143. "email":"bill@engi.com",
  144. "type":"Engineer"
  145. },
  146. {
  147. "id": "pr345",
  148. "name":"Kevin Counter",
  149. "company":"KCQS",
  150. "phone":"013 456 7890",
  151. "mobile":"073 456 7890",
  152. "email":"k@county.com",
  153. "type":"Quantity Surveyor"
  154. }
  155. ],
  156. "contractor": [
  157. {
  158. "id": "con123",
  159. "name":"Leonardo da Vinci",
  160. "company":"MegaBuild",
  161. "phone":"014 567 8901",
  162. "mobile":"074 567 8901",
  163. "email":"leo@buildy.com",
  164. "type":"Main"
  165. },
  166. {
  167. "id": "con234",
  168. "name":"Steve Cleer",
  169. "company":"SC Civils",
  170. "phone":"015 678 9012",
  171. "mobile":"075 678 9012",
  172. "email":"sc@earthy.com",
  173. "type":"Civil"
  174. },
  175. {
  176. "id": "con345",
  177. "name":"Warren Fright",
  178. "company":"Electrified",
  179. "phone":"016 789 0123",
  180. "mobile":"076 789 0123",
  181. "email":"@sparky.com",
  182. "type":"Electrical"
  183. }
  184. ]
  185. }
  186. },
  187. {
  188. "id": "345-uni-que",
  189. "name": "Rolling Stock",
  190. "status": "Out to Tender",
  191. "category": "Commercial",
  192. "type": "Office Block",
  193. "updated": "21 March 2023",
  194. "value": 300000000,
  195. "units": 3,
  196. "address": {
  197. "erf": "103-RE",
  198. "street": "Third Avenue",
  199. "street2": "",
  200. "town": "Swellendam",
  201. "city": "Drakenstein",
  202. "region": "Western Cape",
  203. "postalCode": "333"
  204. },
  205. "contacts": {
  206. "professional": [
  207. {
  208. "id": "pr123",
  209. "name":"Charles Darwin",
  210. "company":"Darwin Designs",
  211. "phone":"011 234 5678",
  212. "mobile":"071 234 5678",
  213. "email":"darwin@archi.com",
  214. "type":"Architect"
  215. <details>
  216. <summary>英文:</summary>
  217. struct Welcome: Codable {
  218. let projectGetResult: Bool
  219. let projectGetProjects: [ProjectGetProject]
  220. }
  221. struct ProjectGetProject: Codable {
  222. let id, name, status, category: String
  223. let type, updated: String
  224. let value, units: Int
  225. let address: Address
  226. let contacts: Contacts
  227. }
  228. struct Address: Codable {
  229. let erf, street, street2, town: String
  230. let city, region, postalCode: String
  231. }
  232. struct Contacts: Codable {
  233. let professional, contractor: [Contractor]
  234. }
  235. struct Contractor: Codable {
  236. let id, name, company, phone: String
  237. let mobile, email, type: String
  238. }
  239. class ViewController: UIViewController {
  240. let stringThing = &quot;&quot;&quot;
  241. {
  242. &quot;projectGetResult&quot;: true,
  243. &quot;projectGetProjects&quot;: [
  244. {
  245. &quot;id&quot;: &quot;123-uni-que&quot;,
  246. &quot;name&quot;: &quot;Amazon&quot;,
  247. &quot;status&quot;: &quot;Planning&quot;,
  248. &quot;category&quot;: &quot;Commercial&quot;,
  249. &quot;type&quot;: &quot;Office Block&quot;,
  250. &quot;updated&quot;: &quot;21 March 2023&quot;,
  251. &quot;value&quot;: 100000000,
  252. &quot;units&quot;: 1,
  253. &quot;address&quot;: {
  254. &quot;erf&quot;: &quot;101-RE&quot;,
  255. &quot;street&quot;: &quot;First Avenue&quot;,
  256. &quot;street2&quot;: &quot;&quot;,
  257. &quot;town&quot;: &quot;Cape Town&quot;,
  258. &quot;city&quot;: &quot;Cape Town&quot;,
  259. &quot;region&quot;: &quot;Western Cape&quot;,
  260. &quot;postalCode&quot;: &quot;111&quot;
  261. },
  262. &quot;contacts&quot;: {
  263. &quot;professional&quot;: [
  264. {
  265. &quot;id&quot;: &quot;pr123&quot;,
  266. &quot;name&quot;:&quot;Charles Darwin&quot;,
  267. &quot;company&quot;:&quot;Darwin Designs&quot;,
  268. &quot;phone&quot;:&quot;011 234 5678&quot;,
  269. &quot;mobile&quot;:&quot;071 234 5678&quot;,
  270. &quot;email&quot;:&quot;darwin@archi.com&quot;,
  271. &quot;type&quot;:&quot;Architect&quot;
  272. },
  273. {
  274. &quot;id&quot;: &quot;pr234&quot;,
  275. &quot;name&quot;:&quot;Bill Hutchins&quot;,
  276. &quot;company&quot;:&quot;Hutchins Engineering&quot;,
  277. &quot;phone&quot;:&quot;012 345 6789&quot;,
  278. &quot;mobile&quot;:&quot;072 345 6789&quot;,
  279. &quot;email&quot;:&quot;bill@engi.com&quot;,
  280. &quot;type&quot;:&quot;Engineer&quot;
  281. },
  282. {
  283. &quot;id&quot;: &quot;pr345&quot;,
  284. &quot;name&quot;:&quot;Kevin Counter&quot;,
  285. &quot;company&quot;:&quot;KCQS&quot;,
  286. &quot;phone&quot;:&quot;013 456 7890&quot;,
  287. &quot;mobile&quot;:&quot;073 456 7890&quot;,
  288. &quot;email&quot;:&quot;k@county.com&quot;,
  289. &quot;type&quot;:&quot;Quantity Surveyor&quot;
  290. }
  291. ],
  292. &quot;contractor&quot;: [
  293. {
  294. &quot;id&quot;: &quot;con123&quot;,
  295. &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
  296. &quot;company&quot;:&quot;MegaBuild&quot;,
  297. &quot;phone&quot;:&quot;014 567 8901&quot;,
  298. &quot;mobile&quot;:&quot;074 567 8901&quot;,
  299. &quot;email&quot;:&quot;leo@buildy.com&quot;,
  300. &quot;type&quot;:&quot;Main&quot;
  301. },
  302. {
  303. &quot;id&quot;: &quot;con234&quot;,
  304. &quot;name&quot;:&quot;Steve Cleer&quot;,
  305. &quot;company&quot;:&quot;SC Civils&quot;,
  306. &quot;phone&quot;:&quot;015 678 9012&quot;,
  307. &quot;mobile&quot;:&quot;075 678 9012&quot;,
  308. &quot;email&quot;:&quot;sc@earthy.com&quot;,
  309. &quot;type&quot;:&quot;Civil&quot;
  310. },
  311. {
  312. &quot;id&quot;: &quot;con345&quot;,
  313. &quot;name&quot;:&quot;Warren Fright&quot;,
  314. &quot;company&quot;:&quot;Electrified&quot;,
  315. &quot;phone&quot;:&quot;016 789 0123&quot;,
  316. &quot;mobile&quot;:&quot;076 789 0123&quot;,
  317. &quot;email&quot;:&quot;@sparky.com&quot;,
  318. &quot;type&quot;:&quot;Electrical&quot;
  319. }
  320. ]
  321. }
  322. },
  323. {
  324. &quot;id&quot;: &quot;234-uni-que&quot;,
  325. &quot;name&quot;: &quot;TBC SA&quot;,
  326. &quot;status&quot;: &quot;On Site&quot;,
  327. &quot;category&quot;: &quot;Commercial&quot;,
  328. &quot;type&quot;: &quot;Office Block&quot;,
  329. &quot;updated&quot;: &quot;21 March 2023&quot;,
  330. &quot;value&quot;: 200000000,
  331. &quot;units&quot;: 2,
  332. &quot;address&quot;: {
  333. &quot;erf&quot;: &quot;102-RE&quot;,
  334. &quot;street&quot;: &quot;Second Avenue&quot;,
  335. &quot;street2&quot;: &quot;Corner of 4th&quot;,
  336. &quot;town&quot;: &quot;Stellenbosch&quot;,
  337. &quot;city&quot;: &quot;Cape Town&quot;,
  338. &quot;region&quot;: &quot;Western Cape&quot;,
  339. &quot;postalCode&quot;: &quot;222&quot;
  340. },
  341. &quot;contacts&quot;: {
  342. &quot;professional&quot;: [
  343. {
  344. &quot;id&quot;: &quot;pr123&quot;,
  345. &quot;name&quot;:&quot;Charles Darwin&quot;,
  346. &quot;company&quot;:&quot;Darwin Designs&quot;,
  347. &quot;phone&quot;:&quot;011 234 5678&quot;,
  348. &quot;mobile&quot;:&quot;071 234 5678&quot;,
  349. &quot;email&quot;:&quot;darwin@archi.com&quot;,
  350. &quot;type&quot;:&quot;Architect&quot;
  351. },
  352. {
  353. &quot;id&quot;: &quot;pr234&quot;,
  354. &quot;name&quot;:&quot;Bill Hutchins&quot;,
  355. &quot;company&quot;:&quot;Hutchins Engineering&quot;,
  356. &quot;phone&quot;:&quot;012 345 6789&quot;,
  357. &quot;mobile&quot;:&quot;072 345 6789&quot;,
  358. &quot;email&quot;:&quot;bill@engi.com&quot;,
  359. &quot;type&quot;:&quot;Engineer&quot;
  360. },
  361. {
  362. &quot;id&quot;: &quot;pr345&quot;,
  363. &quot;name&quot;:&quot;Kevin Counter&quot;,
  364. &quot;company&quot;:&quot;KCQS&quot;,
  365. &quot;phone&quot;:&quot;013 456 7890&quot;,
  366. &quot;mobile&quot;:&quot;073 456 7890&quot;,
  367. &quot;email&quot;:&quot;k@county.com&quot;,
  368. &quot;type&quot;:&quot;Quantity Surveyor&quot;
  369. }
  370. ],
  371. &quot;contractor&quot;: [
  372. {
  373. &quot;id&quot;: &quot;con123&quot;,
  374. &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
  375. &quot;company&quot;:&quot;MegaBuild&quot;,
  376. &quot;phone&quot;:&quot;014 567 8901&quot;,
  377. &quot;mobile&quot;:&quot;074 567 8901&quot;,
  378. &quot;email&quot;:&quot;leo@buildy.com&quot;,
  379. &quot;type&quot;:&quot;Main&quot;
  380. },
  381. {
  382. &quot;id&quot;: &quot;con234&quot;,
  383. &quot;name&quot;:&quot;Steve Cleer&quot;,
  384. &quot;company&quot;:&quot;SC Civils&quot;,
  385. &quot;phone&quot;:&quot;015 678 9012&quot;,
  386. &quot;mobile&quot;:&quot;075 678 9012&quot;,
  387. &quot;email&quot;:&quot;sc@earthy.com&quot;,
  388. &quot;type&quot;:&quot;Civil&quot;
  389. },
  390. {
  391. &quot;id&quot;: &quot;con345&quot;,
  392. &quot;name&quot;:&quot;Warren Fright&quot;,
  393. &quot;company&quot;:&quot;Electrified&quot;,
  394. &quot;phone&quot;:&quot;016 789 0123&quot;,
  395. &quot;mobile&quot;:&quot;076 789 0123&quot;,
  396. &quot;email&quot;:&quot;@sparky.com&quot;,
  397. &quot;type&quot;:&quot;Electrical&quot;
  398. }
  399. ]
  400. }
  401. },
  402. {
  403. &quot;id&quot;: &quot;345-uni-que&quot;,
  404. &quot;name&quot;: &quot;Rolling Stock&quot;,
  405. &quot;status&quot;: &quot;Out to Tender&quot;,
  406. &quot;category&quot;: &quot;Commercial&quot;,
  407. &quot;type&quot;: &quot;Office Block&quot;,
  408. &quot;updated&quot;: &quot;21 March 2023&quot;,
  409. &quot;value&quot;: 300000000,
  410. &quot;units&quot;: 3,
  411. &quot;address&quot;: {
  412. &quot;erf&quot;: &quot;103-RE&quot;,
  413. &quot;street&quot;: &quot;Third Avenue&quot;,
  414. &quot;street2&quot;: &quot;&quot;,
  415. &quot;town&quot;: &quot;Swellendam&quot;,
  416. &quot;city&quot;: &quot;Drakenstein&quot;,
  417. &quot;region&quot;: &quot;Western Cape&quot;,
  418. &quot;postalCode&quot;: &quot;333&quot;
  419. },
  420. &quot;contacts&quot;: {
  421. &quot;professional&quot;: [
  422. {
  423. &quot;id&quot;: &quot;pr123&quot;,
  424. &quot;name&quot;:&quot;Charles Darwin&quot;,
  425. &quot;company&quot;:&quot;Darwin Designs&quot;,
  426. &quot;phone&quot;:&quot;011 234 5678&quot;,
  427. &quot;mobile&quot;:&quot;071 234 5678&quot;,
  428. &quot;email&quot;:&quot;darwin@archi.com&quot;,
  429. &quot;type&quot;:&quot;Architect&quot;
  430. },
  431. {
  432. &quot;id&quot;: &quot;pr234&quot;,
  433. &quot;name&quot;:&quot;Bill Hutchins&quot;,
  434. &quot;company&quot;:&quot;Hutchins Engineering&quot;,
  435. &quot;phone&quot;:&quot;012 345 6789&quot;,
  436. &quot;mobile&quot;:&quot;072 345 6789&quot;,
  437. &quot;email&quot;:&quot;bill@engi.com&quot;,
  438. &quot;type&quot;:&quot;Engineer&quot;
  439. },
  440. {
  441. &quot;id&quot;: &quot;pr345&quot;,
  442. &quot;name&quot;:&quot;Kevin Counter&quot;,
  443. &quot;company&quot;:&quot;KCQS&quot;,
  444. &quot;phone&quot;:&quot;013 456 7890&quot;,
  445. &quot;mobile&quot;:&quot;073 456 7890&quot;,
  446. &quot;email&quot;:&quot;k@county.com&quot;,
  447. &quot;type&quot;:&quot;Quantity Surveyor&quot;
  448. }
  449. ],
  450. &quot;contractor&quot;: [
  451. {
  452. &quot;id&quot;: &quot;con123&quot;,
  453. &quot;name&quot;:&quot;Leonardo da Vinci&quot;,
  454. &quot;company&quot;:&quot;MegaBuild&quot;,
  455. &quot;phone&quot;:&quot;014 567 8901&quot;,
  456. &quot;mobile&quot;:&quot;074 567 8901&quot;,
  457. &quot;email&quot;:&quot;leo@buildy.com&quot;,
  458. &quot;type&quot;:&quot;Main&quot;
  459. },
  460. {
  461. &quot;id&quot;: &quot;con234&quot;,
  462. &quot;name&quot;:&quot;Steve Cleer&quot;,
  463. &quot;company&quot;:&quot;SC Civils&quot;,
  464. &quot;phone&quot;:&quot;015 678 9012&quot;,
  465. &quot;mobile&quot;:&quot;075 678 9012&quot;,
  466. &quot;email&quot;:&quot;sc@earthy.com&quot;,
  467. &quot;type&quot;:&quot;Civil&quot;
  468. },
  469. {
  470. &quot;id&quot;: &quot;con345&quot;,
  471. &quot;name&quot;:&quot;Warren Fright&quot;,
  472. &quot;company&quot;:&quot;Electrified&quot;,
  473. &quot;phone&quot;:&quot;016 789 0123&quot;,
  474. &quot;mobile&quot;:&quot;076 789 0123&quot;,
  475. &quot;email&quot;:&quot;@sparky.com&quot;,
  476. &quot;type&quot;:&quot;Electrical&quot;
  477. }
  478. ]
  479. }}]}
  480. &quot;&quot;&quot;
  481. override func viewDidLoad() {
  482. super.viewDidLoad()
  483. do{
  484. let jsonData = stringThing.data(using: .utf8)!
  485. let result = try JSONDecoder().decode(Welcome.self, from: jsonData)
  486. print(result)
  487. }catch{
  488. print(&quot;error&quot;)
  489. }
  490. }
  491. }
  492. </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:

确定