Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Mash-up of ASIHTTPRequest and JSON

branch: master
This is a mash-up of ASIHTTPRequest and JSON; the NIHJSONRequest class derives from ASIHTTPRequest, much like ASIFormDataRequest does, but posts a JSON representation of its postObject property instead of URL-encoded form data.

    #import "NIHJSONRequest.h"

    NIHJSONRequest *request = [NIHJSONRequest requestWithURL:url];
    [request setPostObject:anyObject];

The ASIHTTPRequest+JSON.h header adds a responseJSON method to ASIHTTPRequest that parses the request body as JSON and returns the appropriate NSDictionary or NSArray. Really this just saves typing, but is also perhaps cleaner.

    #import "ASIHTTPRequest+JSON.h"

    NSDictionary *response = [request responseJSON];

The latter is included by the former, so you can call responseJSON on an NIHJSONRequest; it's implemented separately since you'll often expect JSON in response to a GET or even to a form data POST.

Finally, the NIHJSONRequest+OAuth.h header is used in combination with my ASIHTTPRequest+OAuth category (which you'll find at, it extends the NIHJSONRequest class to add an oauth_body_hash parameter for the posted JSON as defined by
Something went wrong with that request. Please try again.