I'm trying to retrieve the data from an API request, however, I'm having trouble parsing some of the nested parts of the JSON data.
The JSON structure looks like this:
And I am trying to retrieve language, market, ask, etc. from this API response. The problem is, I am having trouble casting result as a dictionary.
I cannot convert it to a string nor can I turn it into a usable array. How do I access these values?
The JSON structure looks like this:
Code Block ["quoteResponse": { error = "<null>"; result = ( { ask = "607.65"; gmtOffSetMilliseconds = "-18000000"; language = "en-US"; longName = "Tesla, Inc."; market = "us_market"; } ); }]
And I am trying to retrieve language, market, ask, etc. from this API response. The problem is, I am having trouble casting result as a dictionary.
Code Block Swift if let dictionary = jsonData as? [String: Any] { print(dictionary) if let nestedDictionary = dictionary["quoteResponse"] as? [String: Any] { if let results = nestedDictionary["result"] as? Any{ print(results) } } }
I cannot convert it to a string nor can I turn it into a usable array. How do I access these values?