Hi, I am currently using the enum approach in parsing Custom Scalar from the server.
Its working well. But now I need to submit/pass the same custom scalar to the server, the custom scalar can be a Dictionary or an Array.
Do I have to edit the API.swift to process the enum before sending it to the server?
enum CustomJSON {
case dictionary([String: Any])
case array([Any])
}extension CustomJSON: JSONDecodable {
init(jsonValue value: JSONValue) throws {
if let dict = value as? [String: Any] {
self = .dictionary(dict)
} else if let array = value as? [Any] {
self = .array(array)
} else {
throw JSONDecodingError.couldNotConvert(value: value, to: CustomJSON.self)
}
}
}