We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2745814 commit 409b12eCopy full SHA for 409b12e
Networking/Networking/Mapper/DataBoolMapper.swift
@@ -1,13 +1,17 @@
1
import Foundation
2
3
-/// Mapper: Bool Result Wrapped in `data` Key
+/// Mapper: Bool Result, Wrapped in `data` Key or not
4
///
5
struct DataBoolMapper: Mapper {
6
7
/// (Attempts) to extract the boolean flag from a given JSON Encoded response.
8
9
func map(response: Data) throws -> Bool {
10
- try JSONDecoder().decode(DataBool.self, from: response).data
+ do {
11
+ return try JSONDecoder().decode(DataBool.self, from: response).data
12
+ } catch {
13
+ return try JSONDecoder().decode(Bool.self, from: response)
14
+ }
15
}
16
17
0 commit comments