Contextual type 'AnyObject' cannot be used with dictionary literal - data structure not consistent
<p>I'm trying to setup a simple dictionary in swift:</p>

<pre><code>var dict = [
  "_id": "123",
  "profile": [
    "name": "me",
    "username": nil,
  ]
] as [String : Any]
</code></pre>

<p>However that fails with <code>Contextual type 'AnyObject' cannot be used with dictionary literal</code>. Following <a href="https://stackoverflow.com/a/38065833/2054629">this question</a>, I've tried replacing <code>[String : Any]</code> by <code>[String : [String : Any]]</code>, but that logically fails because the first value is of type <code>String</code> and not <code>[String : Any]</code>.</p>

<p>I'd just want to have something that holds any kind of data I can represent as a json, and I'm fine with having to guard-cast things when trying to access them later on.</p>