Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Objective-C C++ Python
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Benchmarking
Demo
Source
TouchJSON.xcodeproj
UnitTests
LICENSE.txt
README
README.markdown

README.markdown

= Introduction =

TouchJSON is parser and generator for JSON implemented in Objective C.

It is based on Jonathan Wight's CocoaJSON code: http://toxicsoftware.com/cocoajson/

= How to use TouchJSON in your Cocoa or Cocoa Touch application. =

== Setup your project ==

Copy the source files within TouchJSON/Source to your project. The easiest way is to open both projects in Xcode, then drag and drop. Make sure to check "Copy items into destination groups folder (if needed)."

== To transform JSON to objects == Put #import "CJSONDeserializer.h" in your file.

Here is a code sample:

NSString *jsonString = @"yourJSONHere"; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];}

Note that if you don't care about the exact error, you can check that the dictionary returned by deserializeAsDictionary is nil. In that case, use this code sample:

NSString *jsonString = @"yourJSONHere"; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:nil];

== To transform objects to JSON == Put #import "CJSONSerializer.h" in your file.

Here is a code sample:

NSDictionary *dictionary = [NSDictionary dictionaryWithObject:@"b" forKey:@"a"]; NSString *jsonString = [[CJSONSerializer serializer] serializeObject:dictionary];

Something went wrong with that request. Please try again.