Better JSON to Object Serialization

Krzysztof ZabÅ‚ocki: “I donâ€ t like passing around JSON so I write parsing on top of native objects like NSDictionary/NSArray. If you get data as JSON just write a simple category that transforms JSON to native objects using NSJSONSerialization.”

Here’s a nice hunk of code that will save you some time when you write your next iOS App that talks to a web service. I don’t like passing around NSArray or NSDictionary either, or even worse the raw JSON you get back from a service. I’ve written a few times about transforming JSON into an Object, and it’s not hard to do, but it’s so “boilerplate” it feels like a waste of time. Time you could use elsewhere. Krzysztof provides a nice way to get past all that boilerplate code and get automagic serialization of JSON to Object. It’s definitely worth a look and worth understanding the pattern.