removed try
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3f0450547a
commit
a7e32f3ca4
@ -93,7 +93,7 @@ extension JSONDecoder {
|
||||
/// Helper method to initialize a JSONDecoder
|
||||
/// - Parameter delegateObject: Delegate Object
|
||||
/// - Returns: JSONDecoder
|
||||
public class func create(delegateObject: DelegateObject? = nil) throws -> JSONDecoder {
|
||||
public class func create(delegateObject: DelegateObject? = nil) -> JSONDecoder {
|
||||
let decoder = JSONDecoder()
|
||||
decoder.add(value: DecodingContext(), for: .contextKey)
|
||||
if let delegateObject = delegateObject {
|
||||
|
||||
@ -16,7 +16,7 @@ extension JSONDecoder: AnyDecoder {}
|
||||
extension PropertyListDecoder: AnyDecoder {}
|
||||
|
||||
extension Data {
|
||||
public func decode<T: Decodable>(using decoder: AnyDecoder = JSONDecoder(), delegateObject: DelegateObject? = nil) throws -> T {
|
||||
public func decode<T: Decodable>(using decoder: AnyDecoder = JSONDecoder.create(), delegateObject: DelegateObject? = nil) throws -> T {
|
||||
if let decoder = decoder as? JSONDecoder {
|
||||
return try decoder.decode(T.self, from: self, delegateObject: delegateObject)
|
||||
} else {
|
||||
@ -52,7 +52,7 @@ extension Decodable {
|
||||
public static func decode(jsonDict: [String: Any], delegateObject: DelegateObject? = nil) throws -> Self {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: jsonDict)
|
||||
do {
|
||||
let decoder = try JSONDecoder.create(delegateObject: delegateObject)
|
||||
let decoder = JSONDecoder.create(delegateObject: delegateObject)
|
||||
return try jsonData.decode(using: decoder)
|
||||
} catch {
|
||||
throw JSONError.other(error: error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user