user4938361
user4938361

Reputation: 149

'Dictionary' specialized with too few type parameters (got 1, but expected 2) Swift

let df = dict["forms"] as? Array<Dictionary<String,Any>>
    let dfs = dict["forms"] as? Array<Dictionary<Dictionary<String,Any>>>

The second line is what produces the error. I am uncertain of the correct syntax here. I am trying to grab a dictionary inside the dictionary. I don't see why this syntax doesn't work

Upvotes: 0

Views: 2185

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726599

To get the dictionary inside a dictionary you need to specify the key type of the outer dictionary. Assuming it's String, use

Array<Dictionary<String,Dictionary<String,Any>>>
//               ^^^^^^

or

[[String : [String : Any]]]

Upvotes: 2

Related Questions