Last active
April 23, 2023 21:11
-
-
Save d2burke/d6a527280da2ec5cf4a568dad21444e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Profile: Codable { | |
var skills: [ProfileSkill] | |
var styles: [ProfileStyle] | |
var roles: [ProfileRole] | |
} | |
struct ProfileSkill: Codable { | |
var key: String | |
var label: String | |
} | |
struct ProfileStyle: Codable { | |
var key: String | |
var label: String | |
} | |
struct ProfileRole: Codable { | |
var key: String | |
var label: String | |
} | |
let json = """ | |
{ | |
"skills": [ | |
{ | |
"key": "PREMIERE", | |
"label": "Adobe Premiere" | |
}, | |
{ | |
"key": "AFTER_EFFECTS", | |
"label": "After Effects" | |
} | |
], | |
"styles": [ | |
{ | |
"key": "GAMING", | |
"label": "Gaming" | |
}, | |
{ | |
"key": "REACTS", | |
"label": "Reacts" | |
} | |
], | |
"roles": [ | |
{ | |
"key": "EDITOR", | |
"label": "Editor" | |
}, | |
{ | |
"key": "THUMBNAIL_DESIGNER", | |
"label": "Thumbnail Designer" | |
} | |
] | |
} | |
""" | |
let jsonData = json.data(using: .utf8)! | |
let decoder = JSONDecoder() | |
let profile = try! decoder.decode(Profile.self, from: jsonData) | |
print(profile) |
ugiacoman
commented
Apr 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment