Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift pretty print json

extension Data {

    var prettyPrintedJSONString: String? {
        guard
            let object = try? JSONSerialization.jsonObject(with: self, options: []),
            let data = try? JSONSerialization.data(withJSONObject: object, options: .prettyPrinted),
            let prettyPrintedString = String(data: data, encoding: .utf8)
        else { return nil }

        return prettyPrintedString
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift convert string to int 
Swift :: dismiss keyboard on tap outside swiftui 
Swift :: swift infinite while loop 
Swift :: objective c vs swift 
Swift :: swift programmatically set font 
Swift :: how can i find range of a string in another string swift 
Swift :: button click programmatically swift 
Swift :: how to Not bool bindng swiftui 
Swift :: uilabel set font 
Swift :: swift stack view scrollable 
Swift :: how to include a library in swift 
Swift :: swiftui check available ios 
Swift :: swift enum xib 
Swift :: struct vs class in swift 
Swift :: Swift Access Array Elements 
Swift :: printf in swift 
Swift :: xcode how to get aspect ratio of device 
Swift :: swift do catch where 
Swift :: ios tableview hide empty cells 
Swift :: Button on right side/view of UITextField 
Swift :: special symbol ios swift 
Swift :: flow ios swift kotlin 
Swift :: string swift 
Swift :: selector cannot call in notification observer swift 
Swift :: Swift Literals 
Swift :: Swap/Change Rootviewcontroller with Animation ios/swift 
Swift :: sprite kitYourNextScene 
Ruby :: ruby get current datetime 
Ruby :: ruby format date time 
Ruby :: ruby intersection of two arrays 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =