07 October 2011

ObjectMapper an Objective-c lib to map data structure into user-objects

I was working on iPhone project and I needed to consume data from some JSON service.

I've tried to find some library to convert returned JSON String into my own custom objects... but I didn't.

Most popular JSON libraries (JSONKit, SBJson, etc ..) just convert JSON String into Objective-c data structures (NSDictionary, NSArray). So I decided to write a lib to convert from NSDictionary and NSAarry into my own custom-objects.

ObjectMapper [https://github.com/MuhammadHewedy/ObjectMapper] is a project used to convert NSDictaionry to Custom user objects. It can used with JSON parsing libraries (JSONKit, SBJSON, etc) to convert the returned NSDictionary and NSArray into custom user objects

Example usage:

Complete Example project found here : https://github.com/MuhammadHewedy/ObjectMapper/tree/master/ObjectMapperTester
Good luck!

2 comments:

Aaron said...

I noticed that JSONKit dictionaries are JKDictionary type.

Does your ORM create dictionary keys as instance variables by key name? I'm also curious how you handle nested dictionaries.
Either way very cool and can't wait to check this out!

mhewedy said...

Yes, I create dictionary keys as instance variables by key name.

About the nested dictionaries, currently I support just one level, as appears in the example above.

You are welcome to give this a try and tell me your feedback.

BTW, It is used in some app on Apple Store.