Closed 1ud0v1c closed 7 years ago
Hi,
I succeed to deserialize my object thanks to Marshal but I try to do it the other way. To convert my object back to a json string. I don't succeed to be conform to the Marshling protocol. Here is my object:
class MarshalBook : Book, Marshaling, Unmarshaling { required init(object: MarshaledObject) throws { super.init() self.id = try object.value(for: "id") self.title = try object.value(for: "name") self.author = try object.value(for: "author") self.genre = try object.value(for: "genre") self.numpages = try object.value(for: "numpages") self.releaseDate = try object.value(for: "release_date") self.cover = try object.value(for: "cover") } func marshaled() -> [String: Any] { return { "id": id, "name" : title, "author": author, "genre": genre, "numpages": numpages, "release_date": releaseDate, "cover": cover } } }
And I have an error :
Cannot convert return expression of type '() -> String' to return type '[String : Any]'
Did you see, what I'm doing wrong ? Regards
Hi,
I succeed to deserialize my object thanks to Marshal but I try to do it the other way. To convert my object back to a json string. I don't succeed to be conform to the Marshling protocol. Here is my object:
And I have an error :
Did you see, what I'm doing wrong ? Regards