diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift index 38fdc730..d8f5513d 100644 --- a/MVMCoreUI/Models/Decoder.swift +++ b/MVMCoreUI/Models/Decoder.swift @@ -8,7 +8,7 @@ extension JSONDecoder: AnyDecoder {} extension PropertyListDecoder: AnyDecoder {} extension Data { - public func decodeToObject(using decoder: AnyDecoder = JSONDecoder()) throws -> T { + public func decode(using decoder: AnyDecoder = JSONDecoder()) throws -> T { return try decoder.decode(T.self, from: self) } } @@ -27,7 +27,7 @@ extension KeyedDecodingContainerProtocol { } extension Decodable { - public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { + public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self{ guard let path = bundle.path(forResource: fileName, ofType: ".json") else { throw JSONError.pathNotFound } @@ -37,7 +37,7 @@ extension Decodable { } do { - return try jsonData.decode() + return try jsonData.decode() } catch { throw JSONError.other(error: error) } diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift index 1f55038d..93d300f1 100644 --- a/MVMCoreUI/Models/Encoder.swift +++ b/MVMCoreUI/Models/Encoder.swift @@ -8,7 +8,7 @@ extension JSONEncoder: AnyEncoder {} extension PropertyListEncoder: AnyEncoder {} extension Encodable { - public func encodeToData(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { + public func encode(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { return try encoder.encode(self) } @@ -19,7 +19,7 @@ extension Encodable { public func toJSONString() -> String? { guard let data = try? self.encode(), - let string = String(data: data, encoding: .utf8) else { + let string = String(data: data, encoding: .utf8) else{ return nil } return string diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift index 2b51a255..0a9061b9 100644 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ b/MVMCoreUI/Models/JSON/JSONValue.swift @@ -3,7 +3,7 @@ import Foundation public typealias JSONValueArray = [[String: JSONValue]] public typealias JSONValueObject = [String: JSONValue] -public enum JSONValueError: Error { +public enum JSONValueError: Error{ case encode } @@ -105,7 +105,7 @@ extension JSONValue: ExpressibleByDictionaryLiteral { } extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String:JSONValue] { + public func toJSONValue() throws -> [String:JSONValue]{ let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) return try JSONDecoder().decode([String:JSONValue].self, from: data) }