Can I generate nested models from JSON?
Yes. The generator supports nested objects and arrays and outputs corresponding nested model definitions.
Generate NSObject-style Objective-C model classes from JSON examples for legacy iOS, macOS, and Cocoa codebases that still rely on Foundation models.
{
"id": 101,
"name": "Ada Lovelace",
"active": true,
"roles": ["admin", "editor"],
"profile": {
"email": "ada@example.com",
"score": 9.8
}
}
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface UserModel : NSObject
@property (nonatomic, assign) NSInteger id;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, assign) BOOL active;
@property (nonatomic, strong) NSArray<NSString *> *roles;
@end
NS_ASSUME_NONNULL_END
Yes. The generator supports nested objects and arrays and outputs corresponding nested model definitions.
Yes. Use the Force Optional toggle in the app toolbar when you need optional fields in the generated output.