-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with ObjectMapper #1726
Comments
Hi @zocario , do you have a project that you can share that we can use to reproduce the issue? |
Hi @segiddins, check this demo project that crashes with this issue. |
@zocario so, the issue there is that it's using an |
Thanks @segiddins for your answer. |
I solved this issue by making a clone of the object I wanted to transform to JSON
|
I am using Realm on my project (using Swift 1.2) with ObjectMapper to serialize and deserialize JSON Objects I receive and send to my REST Api.
Deserialization of objects works fine, but when I want to serialize one of my Realm object, I am having crashes like this:
Or this if I don't include the primary key of the objects
My Realm objects implement the Mappable protocol of ObjectMapper
I was really surprised to have this kind of error, as Realm acts as if I was editing my objects but I am just creating a JSON dictionary to send them to my API using this code:
This is a known issue on the ObjectMapper repository.
It seems the problem is the custom operator used by ObjectMapper
<=
that makes Realm thinks we want to edit the fields as they are passed asinout
parameters:But this operator, depending on the mapping type (fromJSON or toJSON), will not always edit the inout field. When we are in a "toJSON" case, it'll only read its value and put it in the new JSON dictionary.
The creator of ObjectMapper hasn't find a solution for the moment, and I was wondering if you have any suggestions or pending changes that could help to solve this problem?
The text was updated successfully, but these errors were encountered: