File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed
SwiftyJSONAccelerator/Support Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ extension FileGenerator {
3131 content = content. replacingOccurrences ( of: " {DECLARATION} " , with: declarations)
3232 content = content. replacingOccurrences ( of: " {INITIALIZER} " , with: initialisers)
3333
34+ if modelFile. type == . classType {
35+ content = content. replacingOccurrences ( of: " {REQUIRED} " , with: " required " )
36+ } else {
37+ content = content. replacingOccurrences ( of: " {REQUIRED} " , with: " " )
38+ }
3439 return content
3540 }
3641
Original file line number Diff line number Diff line change @@ -100,7 +100,8 @@ struct SwiftJSONModelFile: ModelFile {
100100 if isArray {
101101 variableType = " [ \( type) ] "
102102 }
103+ let component = constantName. components ( separatedBy: " . " )
103104 let decodeMethod = isOptional ? " decodeIfPresent " : " decode "
104- return " \( name) = try container. \( decodeMethod) ( \( variableType) .self, forKey: . \( constantName ) ) "
105+ return " \( name) = try container. \( decodeMethod) ( \( variableType) .self, forKey: . \( component . last! ) ) "
105106 }
106107}
Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ import Foundation
99
1010{OBJECT_KIND} {OBJECT_NAME}: Codable {
1111
12- enum CodingKeys: CodingKey {
12+ enum CodingKeys: String, CodingKey {
1313{STRING_CONSTANT}
1414 }
1515
1616{DECLARATION}
1717
18- init(from decoder: Decoder) throws {
18+ {REQUIRED} init(from decoder: Decoder) throws {
1919 let container = try decoder.container(keyedBy: CodingKeys.self)
2020{INITIALIZER}
2121 }
Original file line number Diff line number Diff line change 1919 <key >CFBundleShortVersionString </key >
2020 <string >2.0 </string >
2121 <key >CFBundleVersion </key >
22- <string >12 </string >
22+ <string >13 </string >
2323 <key >LSApplicationCategoryType </key >
2424 <string >public.app-category.developer-tools </string >
2525 <key >LSMinimumSystemVersion </key >
You can’t perform that action at this time.
0 commit comments