icanzilb/JSONModel — pull request #140 by ahfarmer (2013-12-18 21:10:11+00:00)
Title: Automatically ignore all readonly properties

Ignore any `readonly` property: any property without a setter.

This change fixes issues with `readonly` properties like this:

@interface MYObject : JSONModel

@property (nonatomic, readonly) NSString *shortDescription;
@property (nonatomic, readonly) int count;

@end

Prior to this change, using `readonly` properties would cause issues when JSON encoding and then decoding, like this:

MYObject *original = [[MYObject alloc] init];
NSString *jsonString = [original toJSONString];
MYObject *recreated = [[MYObject alloc] initWithString:jsonString error: nil];

The above code will throw this error:

this class is not key value coding-compliant for the key shortDescription

In addition to fixing the above error, this change keeps the output JSON string more concise by avoiding printing out the `readonly` properties (which is always duplicate data).

The only current workaround is to use the `` protocol, which does not work on primitive types.

Let me know if you would like me to make any changes or additions before accepting the pull request - thanks!