Latest 0.0.3
License MIT
Platforms ios 7.0, requires ARC

A simple JSON parsing library that aims to adhere to the JSON spec with a sprinkle of type safety.


  • Keep in touch with the structure and limitations of JSON. It’s pretty simple.
  • Take advantage of the type-system to help avoid bugs without adding too much effort.
  • Allow you to index into objects and arrays without performing type-checks at each step.


Parse some JSON

NSData *profileData = [@"{ "name": "Mickey Mouse", "details": { "age": 102, "species": "mouse" }, "animated": true, "friends": ["Minnie", "Goofy", "Donald"] }" dataUsingEncoding:NSUTF8StringEncoding];
TypeJSON *profileJSON = [TypeJSON fromData:data];

Access values with subscript notation and type coersion

NSString *mickeysName = profileJSON["name"].asString;
BOOL isAnimated = profileJSON["animated"].isTrue;
NSInteger mickeysAge = profileJSON["details"]["age"].asNumber.integerValue;
NSString *mickeysSpecies = profileJSON["details"]["species"].asString;
NSString *mickeysFirstFriendsName = profileJSON["friends"][0].asString;

Handle errors when data shape does not meet assumptions

JSON *minniesNameJSON = profileJSON["friends"][0]["name"]; // => JSON
NSString *minniesName = minniesNameJSON.asString; // => nil
NSError *minniesNameError = minniesNameJSON.asError; // => NSError(domain: JSON, code: 422)
NSString *mickeysLocation = profileJSON["location"].asError; // => NSError(domain: JSON, code: 404)

Perform explicit type-checking when data type is not known in advance

profileJSON.isObject; // => YES
profileJSON["name"].isString // => YES
profileJSON["animated"].isString // => NO
profileJSON["animated"].isTrue // => YES

Serialize values back to JSON data

NSData *profileData = profileJSON.asJSON; // => { "name": "Mickey Mouse", "details": { "age": 102, "species": "mouse" }, "animated": true, "friends": ["Minnie", "Goofy", "Donald"] } as NSData
NSData *detailsData = profileJSON["details"].asJSON; // => { "age": 102, "species": "mouse" } as NSData

Create JSON from scratch

TypeJSON *myJSON = [TypeJSON emptyObject];
// TODO: Mutator methods


Some missing features include:

  • Add setters that allow you to construct JSON
  • Implement copy-on-write—or at least avoid creating new objects in -objectForKeyedSubscript: and -objectAtIndexedSubscript:



Standard MIT license. Enjoy.

Latest podspec

    "name": "TypeJSON",
    "version": "0.0.3",
    "summary": "Simple, type-safe JSON parsing",
    "description": "    A simple JSON parsing library that aims to adhere to the JSON spec with a sprinkle of type safety.n",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Mickey Reiss": "[email protected]"
    "source": {
        "git": "",
        "tag": "v0.0.3"
    "platforms": {
        "ios": "7.0"
    "requires_arc": true,
    "source_files": "TypeJSON.{m,h}",
    "compiler_flags": "-Wall -Werror -Wextra",
    "xcconfig": {

Pin It on Pinterest

Share This