Loading ...
Sorry, an error occurred while loading the content.

251Cocoa / Mac OS X: json categories for NSDictionary

Expand Messages
  • Blake Seely
    Feb 6, 2006

      If you're using JSON along with Cocoa on Mac OS X, I created two
      categories on NSDictionary that may be useful:

      +[NSDictionary dictionaryWithJSONString:] - This takes an NSString
      containing JSON and returns an NSDictionary object with key-value
      pairs matching those in the JSON. You can easily access all the
      values using -objectForKey: and, if you make a mutable copy, use
      setObject:forKey: as well.

      -[NSDictionary jsonStringValue:] - This takes your dictionary and
      returns a valid JSON string that you can then send to a URL, etc.

      Here's a URL to the posting and the code:

      Please let me know if you find it useful, have comments, find bugs, etc.


      [Non-text portions of this message have been removed]