I want to improve my class description function by allowing it to display nested custom objects in a neat JSON
style.
Currently I do this:
- (NSString *)description
{
NSDictionary *dict = @{
@"streetName": self.streetName ? : @"",
@"streetNumberArray": self.streetNumberArray ? : @"",
@"otherInfo": self.otherInfo ? : @"",
@"startTime" : self.startTime ? : @"",
@"endTime": self.endTime ? : @"",
@"startWeekday": self.startWeekday ? : @"",
@"address" : self.address ? : @"",
@"type" : self.type ? : @"",
@"parkingDistrict" : self.parkingDistrict ? : @""
};
return [dict description];
}
But I want to add my custom object property (which itself has a similar description method.) so I get something like this when I print out my custom parent object.
{
"users": [
{
"userId": 1,
"firstName": "Acting user",
"lastName": "Number Uno",
"email": "acting1@gmail.com",
"accountId": 1,
"friends" : [
{
"userId": 2,
"firstName": "Acting user",
"lastName": "Number Dos",
"email": "acting2@gmail.com",
"accountId": 2,
"appKey": "097c38869f72114aee3f58dced9fdddf7ce703b92947"
}
]
}
]
}
How can I do that?