One of the shortcomings of JSONDecoder is that it always creates a full object. For my use-case, this is not enough, because my API will send incremental changes, i.e. only the properties of an object that have been changed on server-side. So I am wondering how I can best handle this scenario with Swift.
In JavaScript, this would be pretty easy, using the spread operator, e.g.:
user = {
...user,
...partialUserData
}
The only solution I have found for Swift this far is rather complex:
stablekernel{.}com/article/understanding-extending-swift-4-codable/
Is there any better / easier solution with the latest Swift versions?
(I also found SwiftyJSON
. This actually resembles the way a JSON library for C# I was using implemented it. However, this approach requires to setup the model objects from the parsed JSON yourself. Also, the maintainers seem to have dropped the project.)