Created
January 3, 2020 05:35
-
-
Save Krishna21Soni13/f2f1cccbb47c72ff7d09e911e5c14693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
extension UIApplication { | |
static func jsonString(from object:Any) -> String? { | |
guard let data = jsonData(from: object) else { | |
return nil | |
} | |
return String(data: data, encoding: String.Encoding.utf8) | |
} | |
static func jsonData(from object:Any) -> Data? { | |
guard let data = try? JSONSerialization.data(withJSONObject: object, options: []) else { | |
return nil | |
} | |
return data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment