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

251Cocoa / Mac OS X: json categories for NSDictionary

Expand Messages
  • Blake Seely
    Feb 6, 2006
    • 0 Attachment
      All,

      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:
      http://blakeseely.com/blog/archives/2006/02/06/nsdictionary-
      dictionarywithjsonstring/

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

      -blake

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