I do not understand anything about EvReflection, but I can help you serialize your json using Swift JSONSerialization's native API to convert json data:
First you should get used to always using structs instead of classes if you are not subclassing NSObject or another class.
Do not use IUO (implicitly unwrapped optional) if it is not necessary and do not add the name of your class or structure to the name of your properties. Always start with let when you declare your properties. In short, create a structure with a fallible initializer as follows:
struct Ingredient {
let id: Int
let nome: String
let adicional: Bool
let valorAdicional: Double
let empresa: Int
init?(json: Data) {
guard let json = (try? JSONSerialization.jsonObject(with: json, options: [])) as? [String: Any] else { return nil }
self.id = json["idIngrediente"] as? Int ?? 0
self.nome = json["nomeIngrediente"] as? String ?? ""
self.adicional = json["adicional"] as? Bool ?? false
self.valorAdicional = json["valorAdicional"] as? Double ?? 0
self.empresa = json["empresa"] as? Int ?? 0
}
}
Testing
let json = "{\"adicional\":false,\"empresa\":500,\"idIngrediente\":508,\"valorAdicional\":1.99,\"nomeIngrediente\":\"Ketchup\"}"
let data = Data(json.utf8)
if let ingredient = Ingredient(json: data) {
print(ingredient.id) // "508\n"
print(ingredient.nome) // "Ketchup\n"
print(ingredient.adicional) // "false\n"
print(ingredient.valorAdicional) // "1.99\n"
print(ingredient.empresa) // "500\n"
}