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 SwiftUI | |
struct Car: Identifiable, Hashable, Equatable { | |
let id = UUID() | |
let model: String | |
let team: String | |
static func cars() -> [Self] { | |
[ | |
.init(model: "SF23", team: "Ferrari"), |
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
public extension Dictionary { | |
/// Returns a pretty printed JSON version of the current dictionary. | |
/// String uses white space and indentation to make the resulting data more readable. | |
var prettyPrintedJson: String { | |
do { | |
let data = try JSONSerialization.data(withJSONObject: self, options: [.withoutEscapingSlashes, .prettyPrinted]) | |
return String(data: data, encoding: .utf8) ?? "" | |
} catch { | |
return "" | |
} |