Lightweight JSON marshaling for Objective-C, with Ruby-like string inflections as a bonus.
-
Install CocoaPods.
-
Add the Podfile to your project root:
pod 'JSONObject'- In your project root, install the pod by entering:
pod install
-
Open the
.xcworkspacefile in your project directory. From now on, use this workspace instead of the.xcodeprojfile. -
Add JSONObject to your model object's class header:
#import <JSONObject/NSObject+JSONObject.h>-
To convert the model object to JSON wrapped in the key name "object":
NSData *json = [myObject toJSON:@"object"];
This JSON data stream is suitable for use in a JSON request.