// 전
struct Model: Codable {
let userInformation: UserInfo
let totalUsers: Int
enum CodingKeys: String, CodingKey {
case userInformation = "user_information"
case totalUsers = "total_users"
}
}
struct UserInfo: Codable {
let isAdmin: Bool
let postCount: Int
let isBanned: Bool
enum CodingKeys: String, CodingKey {
case isAdmin = "is_admin"
case postCount = "post_count"
case isBanned = "is_banned"
}
}
// 매크로 사용 후
@DTO
struct Model {
@Property(key: "user_information") let userInfo: UserInfo
@Property(key: "total_users") let totalUsers: Int
}
@DTO
struct UserInfo {
@Property(key: "is_admin") let isAdmin: Bool
@Property(key: "post_count") let postCount: Int
@Property(key: "is_banned") let isBanned: Bool
}
-
Notifications
You must be signed in to change notification settings - Fork 0
WhiteHyun/DTOMacro
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
JSON 모델 파싱을 매크로로 간단하게
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published