Here is the code for the below Json output:
let params : [[String : AnyObject]] = [[\"name\" : \"action\", \"value\" : \"pay\" ],[\"name\" : \"cartJsonData\
Swift (as of December 3, 2020)
func jsonToString(json: AnyObject){
do {
let data1 = try JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions.prettyPrinted) // first of all convert json to the data
let convertedString = String(data: data1, encoding: String.Encoding.utf8) // the data will be converted to the string
print(convertedString ?? "defaultvalue")
} catch let myJSONError {
print(myJSONError)
}
}