URLDecoderProtocol
public protocol URLDecoderProtocol
A protocol for decoding URLCodable objects from a URL’s query parameters.
-
decode(type:Default implementationfrom: decoder: ) Decodes a
URLCodableobject from the given URL using a providedJSONDecoder.Throws
An error if decoding fails.Default Implementation
Provides a default implementation that uses a
JSONDecoder.Declaration
Swift
func decode<T: URLCodable>( type: T.Type, from url: URL, decoder: JSONDecoder ) throws -> TParameters
typeThe type conforming to
URLCodableto decode.urlThe URL containing the query parameters for decoding.
decoderThe
JSONDecoderused for decoding. Defaults to a newJSONDecoderif not provided.Return Value
A decoded instance of the specified type.