title: Handling duplicate key values in swift dictionary
body: <p>I have to comply with a Restful request call using Swift 3 that unfortunately contains duplicate keys as shown below. I originally placed the data in a dictionary to pass into a JSON serialization call. </p>
  
  <pre class="lang-json prettyprint-override"><code>       [
            "mid":"3",
            "attributes":[
                  "carID":["a":54123,"b":424,"c":"13242"],
                  "update":"true"
                  "update":"gold" 
            ]
          ]
  </code></pre>
  
  <p>Notice that update occurs twice, which causes this error:</p>
  
  <blockquote>
    <p>fatal error: Dictionary literal contains duplicate keys</p>
  </blockquote>
  
  <p>I've reviewed this <a href="https://stackoverflow.com/questions/34569546/how-to-avoid-duplicate-key-error-in-swift-when-iterating-over-a-dictionary">question</a> but doesn't seem to have a pertinent answer.</p>
  
  <p>I thought about using an array but I <em>think</em> it would lose the key value pair relationship that I need for the JSON serialization.</p>
  
  <p>I've seen some articles on using structs but I'm not sure that would address the duplicate key issue</p>
  
  <p>Any recommendations? I'm unable to change the parameter names in the request as it is a third party product. </p>
  
  <p>BTW, I don't think my question is a duplicate of <a href="https://stackoverflow.com/questions/34569546/how-to-avoid-duplicate-key-error-in-swift-when-iterating-over-a-dictionary">How to avoid duplicate key error in swift when iterating over a dictionary – Ssswift</a>. That example should truly be a struct/class since it is one key value pair (age:age value) that should be in a class or struct. My example has a repeating key with each of the two instances of the repeating key having different meanings (should they update, and what the updated member type should be). I don't see how it would be applicable but am open to enlightenment on it. </p>
  
  <p>Thanks</p>