Realm-JSON
Realm-JSON copied to clipboard
Custom RLMObject to JSON mapping (symmetric method to +preprocessedJSON needed)
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.
- Why can't
-JSONDictionary
be called directly in the implementation? - Do you have any plans to introduce a symmetric call to
+preprocessedJSON:
? - Are there any other ways I can achieve desired behaviour?
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.