We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe974f0 commit 3a65d5aCopy full SHA for 3a65d5a
Sources/Foundation/Dictionary+FoundationUtils.swift
@@ -50,6 +50,7 @@ extension Dictionary {
50
public func jsonData(prettify: Bool = false) -> Data? {
51
guard JSONSerialization.isValidJSONObject(self) else { return nil }
52
let options = (prettify == true) ? JSONSerialization.WritingOptions.prettyPrinted : JSONSerialization.WritingOptions()
53
+
54
return try? JSONSerialization.data(withJSONObject: self, options: options)
55
}
56
@@ -61,6 +62,7 @@ extension Dictionary {
61
62
/// - Returns: optional JSON String.
63
public func jsonString(prettify: Bool = false) -> String? {
64
guard let jsonData = jsonData(prettify: prettify) else { return nil }
65
66
return String(data: jsonData, encoding: .utf8)
67
68
0 commit comments