Skip to content
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

Identity attribute related swift #16

Closed
wants to merge 23 commits into from

Conversation

ManueGE
Copy link

@ManueGE ManueGE commented Apr 27, 2015

If your JSON has the relationships by referencing the identity attribute instead of by nesting JSONs, you can take advantage of the identityAttributeRelated attribute. For example, if your JSON Dictionary is:

let batmanJSON: JSONObject = [
    "name": "Batman",
    "id": "1699",
    "publisher": 1 
]

you may not want Groot to serialize this dictionary by setting 1 to the Publisher relationship, but by assigning it with the Publisher object which has 1 as its identityAttribute value. You accomplish that by associating the identityAttribute key with true (or any other positive boolean value) in the entity user info dictionary:

Entity User Info

This way, Groot will search in the publisher entity for a entry with the given identity attribute. If it is found, it will assign this entry as the Publisher object of the Character; if it doesn't Groot will create a placeholder Publisher entry with this value for the identity attribute. This placeholder object would be filled eventually if the new data is provided.

Note: To make this feature works, you must always to use the merge methods instead of the insert ones.


Include test cases

@gonzalezreal
Copy link
Owner

Closing as this has been superseded by #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants