Individually selectable standard transformers #214
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Siesta parses JSON by default, using Foundation’s
JSONSerialization
to output dictionaries / arrays. Swift 4’s straight-to-model JSON coding is the happier, better future — but it expects rawData
, not dictionaries. Apps wanting to use the new JSON coding will thus want Siesta’s default JSON parsing disabled. However, they still likely want its default text and image handling.Until now, Siesta’s built-in JSON/image/text parsing has been controlled by
Service.init
’suseDefaultTransformers:
, which is an all-or-nothing proposition. It’s not easy to opt in to only image and text but not JSON. (It’s possible, but it takes quite a hairball of config code.)Solution
This PR adds support for individually selecting default transformers when creating a service:
Services can then easily use Swift 4 JSON coding:
The older
useDefaultTransformers:
is now deprecated in favor ofstandardTransformers:
.The GithubBrowser example project is updated in this PR to use JSON coding. Its example support for SwiftyJSON has moved to
Extensions/
.