How to exclude properties from a JSON dictionary in Mantle

This is just for future reference as the Mantle Framework is pretty awesome, but all of that awesomeness is hidden to most people who don’t wanna read a pile of (well written) source code.

All you have to do is in your implementation of:

+ (NSDictionary*)JSONKeyPathsByPropertyKey
{
    return @{
             @"identifier": @"identifier",
             @"someTransientProperty" : [NSNull null] /* don't provide it a key, provide it a Null */
             };
}

Another note is that Mantle, unless you DO provide these NSNull values, will use your normal propertyKeys as JSON keys. So be sure to provide NSNulls if you don’t want these in your JSON.

Relevant Post: Hands on with the Mantle Framework

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s