Created
May 13, 2022 10:01
-
-
Save nhatduong/849c751a0ad6863936ca25608ed7280a 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
| import Foundation | |
| import SwiftyJSON | |
| struct PostDataCommentsModel { | |
| let comment_oid: String | |
| let content: String | |
| let user: UserPostModel | |
| let media: [PostMediaModel] | |
| init?(json: JSON) { | |
| guard let comment_oid = json["comment_oid"].string, | |
| let content = json["content"].string | |
| else { return nil } | |
| self.comment_oid = comment_oid | |
| self.content = content | |
| let user = json["user"] | |
| let userModel = UserPostModel.init(avatar: user["avatar"].string ?? "", | |
| full_name: user["full_name"].string ?? "", | |
| user_oid: (user["user_oid"].string)!, | |
| user_id: user["user_id"].int ?? 0, | |
| avatar_thumbnail: user["avatar_thumbnail"].string ?? "") | |
| self.user = userModel | |
| if let media = json["media"].array, json["media"].count > 0 { | |
| self.media = media.compactMap(PostMediaModel.init) | |
| } else { | |
| self.media = [PostMediaModel]() | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment