I'm trying to setup a simple dictionary in swift:
var dict = [
"_id": "123",
"profile": [
"name": "me",
"username": nil,
]
] as [String : Any]
However that fails with Contextual type 'AnyObject' cannot be used with dictionary literal
. Following this question, I've tried replacing [String : Any]
by [String : [String : Any]]
, but that logically fails because the first value is of type String
and not [String : Any]
.
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.