Skip to content

Instantly share code, notes, and snippets.

@dterekhov
Last active October 24, 2025 07:40
Show Gist options
  • Select an option

  • Save dterekhov/d88d5c39db23fe21b65befb40af515ae to your computer and use it in GitHub Desktop.

Select an option

Save dterekhov/d88d5c39db23fe21b65befb40af515ae to your computer and use it in GitHub Desktop.
Raw JSON string to specific model #tip #swift-api
@usableFromInline static func generateMockedSid() -> MockedIdentity {
let sidString = UUID().uuidString
let json = #"{"stringValue":"\#(sidString)"}"#
let jsonData = Data(json.utf8)
// swiftlint:disable:next force_try
return try! JSONDecoder().decode(MockedIdentity.self, from: jsonData)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment