Instance Method
decode(_:from:userInfo:)
Decodes an instance of the supplied
Decodable type from a String.func decode<D>(_: D.Type, from string: String, userInfo: [CodingUserInfoKey : any Sendable]) throws -> D where D : Decodable
Parameters
decodableA
DecodabletypeDto decode.stringString to decode a
Dfrom.userInfoOverrides and/or augments the default coder user info.
Return Value
An instance of D.
Discussion
print(data) // "name=Vapor&age=3"
let user = try URLEncodedFormDecoder().decode(User.self, from: data, userInfo: [...])
print(user) // User
Throws
Any error that may occur while attempting to decode the specified type.