StandardTransformer
public struct StandardTransformer
A preconfigured combination of a transformer, content type, and pipeline stage. Use this to individually opt in to Siesta’s built-in response transformers.
-
Uses Foundation’s
JSONSerialization
to transform responses- with content type of
*/json
or*/*+json
- to a dictionary or array
- at the parsing stage.
Disable this if you want to use a different parser, such as Swift 4’s
JSONDecoder
:let service = Service( baseURL: "https://example.com", standardTransformers: [.image, .text]) // no .json let jsonDecoder = JSONDecoder() service.configureTransformer("/foo") { try jsonDecoder.decode(Foo.self, from: $0.content) }
See also
JSONResponseTransformer(_:)
to configure a JSON parser with different options, at a different stage, or for different content types.Declaration
Swift
public static let json: StandardTransformer
- with content type of
-
Parses responses with content type
text/*
as a SwiftString
.See also
TextResponseTransformer(_:)
to configure a text parser with different options, at a different stage, or for different content types.Declaration
Swift
public static let text: StandardTransformer
-
Parses responses with content type
image/*
as a UIKit / AppKit image.See also
ImageResponseTransformer(_:)
to configure an image parser with different options, at a different stage, or for different content types.Declaration
Swift
public static let image: StandardTransformer