Serialize and Deserialize Objective-C objects into

2019-01-07 09:15发布

I need to serialize and deserialize objective-c objects into JSON to store in CouchDB. Do people have any example code for best practice for a general solution? I looked at a few JSON framework and they are stopped at the NSDictionary/NSArray level. i.e. A lot of framework will serialize and deserialize NSDictionary/NSArray into JSON. But I still have to do the work to convert NSDictionary into Objective-C objects.

To make things more complex, my Object A can have reference to an NSArray/NSDictionary of Object Bs.

My question is very similar to this question with addition of the collection requirement.

Instantiating Custom Class from NSDictionary

7条回答
神经病院院长
2楼-- · 2019-01-07 10:13

You may want to try JTObjectMapping. Their description:

JTObjectMapping - Inspired by RestKit. A very simple objective-c framework that maps a JSON response from NSDictionary or NSArray to NSObject subclasses for iOS.

It's very small (unlike RestKit) and works great.

查看更多
登录 后发表回答