title: Should a dictionary be converted to a class or struct in Swift?
body: <p>I am working on a native iOS application that receives data in JSON format from a web-service which we are also in control of. The plan is to change out the backend database in a bout 18 months in favor of a different platform.</p>
  
  <p>With that in mind, we want to be sure that that iOS app is going to be relatively easy to adapt to the new datasource, particularly as we may change the keys used in the associative array received from the server via JSON.</p>
  
  <p>There are two goals:</p>
  
  <ol>
  <li><p>Create a single location for each PHP request where the keys can be modified if needed. This would avoid digging through code to find things like <code>job["jobNumber"]</code>.</p></li>
  <li><p>Clean up our existing code to also eliminate references like <code>job["jobNumber"]</code>.</p></li>
  </ol>
  
  <p>We are both very new to Swift with no Objective-C experience, but I am was thinking a Struct or Class would be appropriate to create references like <code>job.jobNumber</code>.</p>
  
  <p>Should a dictionary be converted into a class or struct? Sample code representing a reusable method of taking a <code>Dictionary&lt;String, String&gt;</code> as shown below and converting it to the recommended type would be extremely helpful.</p>
  
  <p><strong>Example Dictionary:</strong></p>
  
  <pre><code>job = {
      "jobNumber" : "1234",
      "jobName" : "Awards Ceremony",
      "client" : "ACME Productions"
  }
  </code></pre>
  
  <p><strong>Desired result:</strong></p>
  
  <pre><code>println("job name is \(job.name)")
  // prints: job name is Awards Ceremony
  </code></pre>