title: iOS: Serialize/Deserialize complex JSON generically from NSObject class
body: <p>Anyone have  idea how to serialize nested JSON based on NSObject class? There is a discussion to serialize simple JSON <a href="https://stackoverflow.com/questions/10515015/ios-json-serialization-for-nsobject-based-classes">here</a> , but it is not generic enough to cater complex nested JSON.</p>
  
  <p>Imagine this is the result of JSON:</p>
  
  <pre><code>{ "accounting" : [{ "firstName" : "John",  
                      "lastName"  : "Doe",
                      "age"       : 23 },
  
                    { "firstName" : "Mary",  
                      "lastName"  : "Smith",
                      "age"       : 32 }
                                ],                            
    "sales"      : [{ "firstName" : "Sally", 
                      "lastName"  : "Green",
                      "age"       : 27 },
  
                    { "firstName" : "Jim",   
                      "lastName"  : "Galley",
                      "age"       : 41 }
                    ]}
  </code></pre>
  
  <p>From this class:</p>
  
  <pre><code>@interface Person : NSObject{}
  @property (nonatomic, strong) NSString *firstName;
  @property (nonatomic, strong) NSString *lastName;
  @property (nonatomic, strong) NSNumber *age;
  @end
  
  @interface Department : NSObject{}
  @property (nonatomic, strong) NSMutableArray *accounting; //contain Person class
  @property (nonatomic, strong) NSMutableArray *sales; //contain Person class
  @end
  </code></pre>
  
  <p>How to  serialize/deserialize them based on class generically?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Currently i'm able to generate payload  like this based on any class:</p>
  
  <pre><code>NSMutableDictionary *Payload = [self serialize:objClass];
  </code></pre>
  
  <p>But it does not cater  nested complex JSON. Anyone have better solution for this? <a href="http://json.codeplex.com/" rel="nofollow noreferrer">This library</a> for C# cater serialize/deserialze based on object class. I want to reproduce something the same based on NSObject</p>