Is there a way to deserialize a JSON response to a custom object in Swift
WITHOUT having to individually map each element.
Currently I am doing it manually with SwiftyJSON
but it still requires me to map every field redundantly:
var myproperty1 = json["myproperty1"].stringValue
However coming from a C#
background it is as simple as one line of code:
JsonConvert.DeserializeObject<CustomObject>(jsonString); //No mapping needed.
Source - http://www.newtonsoft.com/json/help/html/DeserializeObject.htm
Since I am writing many API endpoints I would like to avoid all the boilerplate mapping code that can be prone to errors. Keep in mind that my JSON responses will be multiple levels deep with arrays of arrays. So any function would need to be recursive.
Similiar question : Automatic JSON serialization and deserialization of objects in Swift