Edit: I have read the other answers on SO for the same issue , however Im unable to get the desired output. I have tried many variations as suggested in other questions but
Additionally, you can just cast to String
let jsonData = try? JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted) let jsonString = String(data: jsonData!, encoding: .utf8)