title: Parsing JSON with wildcard keys
body: <p>I'm parsing a poorly designed JSON structure in which I can expect to find values being reused as keys pointing to further data. Something like this</p>
  
  <pre><code> {"modificationDate" : "..."
    "type" : "...",
    "version" : 2,
    "manufacturer": "&lt;WILDCARD-ID&gt;"
  
    "&lt;WILDCARD-ID&gt;": { /* known structure */ } }
  </code></pre>
  
  <p><code>WILDCARD-ID</code> can be just about anything at runtime, so I can't map it to a field in a struct somewhere at compile time. But once I dereference that field, its value has known structure, at which point I can follow the usual procedure for mapping JSON to <code>struct</code>s.</p>
  
  <p>I've found myself going down this path</p>
  
  <pre><code>let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any]
  let manDict = json["manufacturer"]
  let data = NSKeyedArchiver.archivedData(withRootObject: manDict)
  // now you have data!
  </code></pre>
  
  <p>but this seems very circuitous, which makes me think that maybe there's a cleaner way of accomplishing this?</p>