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

Outbound mapping with keypath into single key #82

Open
originalsk opened this issue Mar 2, 2016 · 1 comment
Open

Outbound mapping with keypath into single key #82

originalsk opened this issue Mar 2, 2016 · 1 comment

Comments

@originalsk
Copy link

Hi. Please, does Realm+JSON somehow supports outbound object mapping from RLMObject into JSON from keypath object.property into key property?

I have object scheme such like:

@interface MyObject

@property NSString * attr1;
@property NSString * attr2;
@property MySubobject * subobject;

@end
@interface MySubobject

@property NSString * attr3;
@property NSNumber<RLMInt> * attr4;

@end

In one specific case I need to create JSON with structure that attr1, attr2, attr3 and attr4 would be on the same level, therefore something like:

+ (NSDictionary *)JSONOutboundMappingDictionary {
    return @{
             @"attr1" : @"attr1",
             @"attr2" : @"attr2",
             @"subobject.attr3" : @"attr3",
             @"subobject.attr4" : @"attr4"
             };
}

So far it keeps crashing and I can't figure out how to achieve such effect without removing MySubobject ale moving all it's attributes into main object (or creating JSON manually from self-created NSDictionary). Is it even possible with Realm+JSON? I noticed inverse case from JSON keypath to single key in RLMObject is allowed. In advance thanks for any answer.

@viktorasl
Copy link
Contributor

I tried achieving the same thing, so finally I have made a modification: introduced JSON preprocessing method, in which you can join your values. #86 is the pull request for that.

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