How can I create JSON string from other model data?
I am looking to create json string from data but not with success.
Results I am getting in array and then I have used For Loop to pass to AppointmentDownloadModel for json creation.
How can I pass data AppointmentDownloadModel and create JSON String.
Data Receiving Model:
struct ResponseData: Codable {
let appointments : [Appointment]?
}
let decoder = JSONDecoder()
let response = try decoder.decode(ResponseData.self, from: result! as! Data)
self.appData = response.appointments
for everyApp in self.appData! {
}
Want to pass response data to this model:
struct AppointmentDownloadModel: Codable{
var appointmentModel: Appointment
var progress: Int = 0
var failedList: [Int: String] = [:]
var isFinished: Bool = false
}
Final need to create this string:
{"appointmentModel":{"appointmentHour":"12:00","backgroundColorDark":"#556f7b","backgroundColorLight":"#cfd8dc","controlHour":"","date":"2020-06-01T12:00:00","heatingType":"b","id":15469622,"isProjectManual":false,"projectFirmName":"Miray Doğalgaz (Erhan Şahin)","projectName":"KÖKSAL ÇOŞKUN-+D1+D3+D5","projectType":"k","subTitle":"18137 902179436-18137-408352"},"failedResourceList":[],"isFinished":false,"progress":0}