diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 165bead..aae6759 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -8,7 +8,7 @@ PODS: - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - HandyJSON (5.0.0-beta.1) - - SmartCodable (3.4.1) + - SmartCodable (3.4.2) - SnapKit (5.6.0) - SQLiteRepairKit (1.3.0): - WCDBOptimizedSQLCipher (~> 1.3.0) @@ -49,7 +49,7 @@ SPEC CHECKSUMS: CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980 FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978 - SmartCodable: 9c9941a8303a8bedb16884a1c6efb27c91851126 + SmartCodable: a99b61311a03dcbeab24d680ab684f61db1d76ea SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 SQLiteRepairKit: a66145aadae91886c800f75e16f5cc6476af1a93 WCDB.swift: 39e28fe29b5a3bf2927d9fb9218978f19bd49ff0 diff --git a/Example/Pods/Local Podspecs/SmartCodable.podspec.json b/Example/Pods/Local Podspecs/SmartCodable.podspec.json index 20a7f4a..35ac990 100644 --- a/Example/Pods/Local Podspecs/SmartCodable.podspec.json +++ b/Example/Pods/Local Podspecs/SmartCodable.podspec.json @@ -1,6 +1,6 @@ { "name": "SmartCodable", - "version": "3.4.1", + "version": "3.4.2", "summary": "数据解析库", "homepage": "https://github.com/intsig171", "license": { @@ -12,7 +12,7 @@ }, "source": { "git": "https://github.com/intsig171/SmartCodable.git", - "tag": "3.4.1" + "tag": "3.4.2" }, "platforms": { "ios": "11.0", diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 165bead..aae6759 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -8,7 +8,7 @@ PODS: - FBSnapshotTestCase/SwiftSupport (2.1.4): - FBSnapshotTestCase/Core - HandyJSON (5.0.0-beta.1) - - SmartCodable (3.4.1) + - SmartCodable (3.4.2) - SnapKit (5.6.0) - SQLiteRepairKit (1.3.0): - WCDBOptimizedSQLCipher (~> 1.3.0) @@ -49,7 +49,7 @@ SPEC CHECKSUMS: CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980 FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978 - SmartCodable: 9c9941a8303a8bedb16884a1c6efb27c91851126 + SmartCodable: a99b61311a03dcbeab24d680ab684f61db1d76ea SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 SQLiteRepairKit: a66145aadae91886c800f75e16f5cc6476af1a93 WCDB.swift: 39e28fe29b5a3bf2927d9fb9218978f19bd49ff0 diff --git a/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist b/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist index 727eee8..b2c5ee6 100644 --- a/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist +++ b/Example/Pods/Target Support Files/SmartCodable/SmartCodable-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.4.1 + 3.4.2 CFBundleSignature ???? CFBundleVersion diff --git a/Example/SmartCodable/TestViewController.swift b/Example/SmartCodable/TestViewController.swift index 9351edc..b005a4d 100644 --- a/Example/SmartCodable/TestViewController.swift +++ b/Example/SmartCodable/TestViewController.swift @@ -30,7 +30,7 @@ class TestViewController: BaseViewController { super.viewDidLoad() let dict: [String: Any] = [ - "age": 10, + "age": "10", "name": "Mccc", "area": "su zhou" ] @@ -44,8 +44,8 @@ class TestViewController: BaseViewController { } struct Home: SmartCodable { var name: String = "" - @IgnoredKey - var age: [Any] = ["1"] + + var age: Int64 = 0 @IgnoredKey var area: String = "area" } diff --git a/SmartCodable.podspec b/SmartCodable.podspec index ccb2e96..80d071b 100644 --- a/SmartCodable.podspec +++ b/SmartCodable.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.name = 'SmartCodable' - s.version = '3.4.1' + s.version = '3.4.2' s.summary = '数据解析库' s.homepage = 'https://github.com/intsig171' diff --git a/SmartCodable/Classes/JSONDecoder/Patcher/Patcher+Transformer.swift b/SmartCodable/Classes/JSONDecoder/Patcher/Patcher+Transformer.swift index bca33e7..6c43301 100644 --- a/SmartCodable/Classes/JSONDecoder/Patcher/Patcher+Transformer.swift +++ b/SmartCodable/Classes/JSONDecoder/Patcher/Patcher+Transformer.swift @@ -83,6 +83,75 @@ extension Int: TypeTransformable { } } +extension Int8: TypeTransformable { + static func transformValue(from value: Any) -> Int8? { + switch value { + case let temp as String: + return Int8(temp) + case let temp as Float: + return Int8(temp) + case let temp as Double: + return Int8(temp) + case let temp as CGFloat: + return Int8(temp) + default: + return nil + } + } +} + +extension Int16: TypeTransformable { + static func transformValue(from value: Any) -> Int16? { + switch value { + case let temp as String: + return Int16(temp) + case let temp as Float: + return Int16(temp) + case let temp as Double: + return Int16(temp) + case let temp as CGFloat: + return Int16(temp) + default: + return nil + } + } +} + + +extension Int32: TypeTransformable { + static func transformValue(from value: Any) -> Int32? { + switch value { + case let temp as String: + return Int32(temp) + case let temp as Float: + return Int32(temp) + case let temp as Double: + return Int32(temp) + case let temp as CGFloat: + return Int32(temp) + default: + return nil + } + } +} + +extension Int64: TypeTransformable { + static func transformValue(from value: Any) -> Int64? { + switch value { + case let temp as String: + return Int64(temp) + case let temp as Float: + return Int64(temp) + case let temp as Double: + return Int64(temp) + case let temp as CGFloat: + return Int64(temp) + default: + return nil + } + } +} + extension Float: TypeTransformable { static func transformValue(from value: Any) -> Float? {