-
Notifications
You must be signed in to change notification settings - Fork 108
Serializing Resources for storage in UserDefaults #184
Comments
@Croge32 have you an example of the JSON which has been written to |
@markst The structure of the object's model is as follows:
I'm trying to serialize an array of these DFPContents objects. They are not coming from JSON, which I suspect is part of the problem. Basically when I just serialize the array itself, the children do populate and their ID and types are assigned, but each of their attributes are nil. I see that in the library itself, it looks like responses are able to be parsed into a I did however find a workaround. I noticed that if I serialize the object AND it's children all in a Resource array, the parents children are also populated with the children's attributes. So I'm able to pass an Here is how I'm serializing in order to get the child attributes to be non-nil:
I have also abandoned UserDefaults and am using a caching library now. Any further insights? I know this probably sounds a bit confusing. |
@markst Any ideas at all? Any suggestions on how I can achieve data persistence using Spine? |
It's most probably not a reason, but have you remembered about adding:
Etc.? EDIT: Nope, it doesn't help :( |
I'm trying to use the Serializer to store objects in UserDefaults so we can load resources up without always doing API requests.
I'm trying to serialize an array of objects that each contain toOne/toMany relationships.
So right now I'm doing:
However when I deserialize this, I have none of the attributes of the relationship objects inside of
contents
, only their ids. Here is how I'm deserializing:I'm not exactly sure what mappingTargets is for. Maybe I'm using that wrong?
How would I go about including the attributes of these relationships when serializing/deserializing?
The text was updated successfully, but these errors were encountered: