Closed richardmcclellan closed 8 years ago
Thanks! Could you please also add a test to SerializingTests
for this?
Sure, I've added a test!
Nice. But I'm wondering, in what cases would you want to omit null values?
@wvteijlingen In the API I am currently working with, if I set an attribute to null on a resource, it will also set that value to null on the server side. I have a UI which updates only a subset of the attributes of a resource, so when I am updating that subset, I want to make sure that only the relevant attributes are sent up, and there is no way for any other attributes to be accidentally changed.
Ah, makes sense. That's a good case for implementing something like dirty checking, but in the meantime, this will work. Thanks again!
I've started working on implementing dirty checking in this branch: https://github.com/wvteijlingen/Spine/tree/dirty-checking.
Since you seem to have the perfect use case for it, you might want to try it. If you do, please let me know whether this works for you!
cheers @richardmcclellan.
Is there anyway I can set this is a global default?
or perhaps to always do so on a POST
operation?
https://github.com/wvteijlingen/Spine/blob/master/Spine/Operation.swift#L250
hi @markst!
For my use case, I was actually only using the serialization part of this library, so some more work may be required in order to utilize the OmitNullValues
option when using Spine's networking interface.
thanks for response @richardmcclellan I've made an issue here https://github.com/wvteijlingen/Spine/issues/94
In cases where you don't want to serialize null values, you can now use the
SerializationOption
,OmitNullValues
.