I am receiving a JSON string from the server and it looks like this:
[[{\"type\":\"action\",\"action\":\"courier_on_map\",\"text\":\"\\u0421\\u043c\\u043e\\u0442\\u0440\\u0435\\u0442\\u044c \\u043d\\u0430 \\u043a\\u0430\\u0440\\u0442\\u0435\"}]]
Web parser says "JSON String is valid but JSON Data is not accurate". JSONSerialization however says:
No string key for value in object around character 1
and returns error.
Code:
func convertToNSDictionary() -> NSDictionary?
{
var string = self
string = string.replacingOccurrences(of: "[", with: "")
string = string.replacingOccurrences(of: "]", with: "")
if let data = string.data(using: .utf8) {
do {
return try JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary
} catch {
print(error.localizedDescription)
}
}
return nil
}