Object to json

do { //Convert to Json data // @param Variable as Anyobject let jsonData = try JSONSerialization.data(withJSONObject: Variable, options: JSONSerialization.WritingOptions.prettyPrinted) //Convert back to string. if let JSONString = String(data: jsonData, encoding: String.Encoding.utf8) { debugPrint(JSONString) } } catch { debugPrint("Error parsing") }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.