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

Custom RLMObject to JSON mapping (symmetric method to +preprocessedJSON needed) #92

Open
pankkor opened this issue Jun 20, 2016 · 1 comment

Comments

@pankkor
Copy link

pankkor commented Jun 20, 2016

If I want to make any complicated preprocessing on JSON before mapping JSON to RLMObject I can use +preprocessedJSON:, but there is no way for opposite postprocessing of RLMObject to JSON if I want to get the same JSON back from RLMObject.

One way I wanted to achieve that is by overriding -JSONDictionary but it is implemented this way:
- (NSDictionary *)JSONDictionary { return [self mc_createJSONDictionary]; }
and everywhere in the implementation -mc_createJSONDictionary is called. So suddenly to achieve what I want I need to override -mc_createJSONDictionary and mess with guts of implementation because -mc_createJSONDictionary is private.

  1. Why can't -JSONDictionary be called directly in the implementation?
  2. Do you have any plans to introduce a symmetric call to +preprocessedJSON:?
  3. Are there any other ways I can achieve desired behaviour?
@pankkor pankkor changed the title custom RLMObject to JSON mapping (symmetric method to +preprocessedJSON needed) Custom RLMObject to JSON mapping (symmetric method to +preprocessedJSON needed) Jun 20, 2016
@viktorasl
Copy link
Contributor

viktorasl commented Jun 21, 2016

JSONOutboundMappingDictionary method works fine, just make readonly property with all needed preprocessed data and map it. Some time ago I've made a PR for preprocessing of each object separately #63.

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

No branches or pull requests

2 participants