danialmoghaddam
danialmoghaddam

Reputation: 443

JSON to NSObject model tool

I was wondering if there is any tool which you can paste a JSON (sample web service response) to generate the NSObject data model (create .h .m files as well as defining the properties) automatically.

Let's say you have the following simple JSON:

{
  "firstName": "Alex",
  "lastName": "Morgan"
}

Use the tool to generate person.h & person.m files like this:

@interface Person : NSObject
@property (nonatomic) NSString *firstName;
@property (nonatomic) NSString *lastName;
@end

@implementation Person
@end

Later, just import the files into the project and use them.

Visual Studio has this feature called Paste Special.

Upvotes: 0

Views: 583

Answers (2)

tilo
tilo

Reputation: 14169

Give JSONExport a try:

JSONExport is a desktop application for Mac OS X which enables you to export JSON objects as model classes with their associated constructors, utility methods, setters and getters in your favorite language.

Upvotes: 3

ShahiM
ShahiM

Reputation: 3268

Try these Xcode plugins : ESJsonFormat-Xcode and XWJsonToCode.

You will need to install the Alcatraz plugin first though.

Upvotes: 1

Related Questions