I am using Supabase RealTime API in Swift. It returns an action, which consists of record. Record is of type [String: AnyJSON]. I want to convert it into ChatMessage struct. ChatMessage struct is shown below:
struct ChatMessage: Codable, Identifiable {
var id: Int?
var text: String
var userId: UUID
private enum CodingKeys: String, CodingKey {
case id = "id"
case text = "text"
case userId = "user_id"
}
}
How can I convert record ([String: AnyJSON]) to ChatMessage?