A json like this:
{
"data": {
"cat" : "Tom",
"dog" : "Teddy"
}
}
json.rawString()
json.rawString([:])
{"dat":{"cat":"Tom","dog":"Teddy"}}
{n "data" : {n "cat" : "Tom",n "dog" : "Teddy"n }n}
//formated
Now I did like this. It works well so far.
import SwiftyJSON
extension JSON {
func toString() -> String? {
return self.rawString()?.replacingOccurrences(of: "\\s", with: "", options: String.CompareOptions.regularExpression, range: nil)
}
}
But not tested enough for more situations.
And, Asking for a better function name to replace "toString:" :-<
Seems like #837 doesn't work in Swift 4. Any idea to create a PR for this?
Try this
json.rawString(.utf8, options: .init(rawValue: 0))
Same issue
Try this
json.rawString(.utf8, options: .init(rawValue: 0))
This works for me in Swift 4, SwiftyJSON 4
Linked to #966
Most helpful comment
Try this
json.rawString(.utf8, options: .init(rawValue: 0))