iPhone + JSON + Reflection iPhone + JSON + Reflection json json

iPhone + JSON + Reflection


There is an open source project called objectiveresource and objectivesupport. They are partial Objective-C implementations of a what is called ActiveResource and ActiveSupport in the Ruby and RESTful development world. Part of what objectivesupport does is serializing and deserializing JSON (as well as XML) object. If you don't want to use the full frameworks as is, you can take a look at the source code for objectivesupport and there you will see their implementation of serializing to/from an NSObject. The specific code you want to look at are listed below: (Basically implemented as a category on the NSObject, NSArray and NSDictionary types) http://github.com/yfactorial/objectivesupport/tree/d08b5be6c0f7a2b0196b6ec17e4441bb146c4e23/Classes/lib/Serialization/JSON

BTW, they seem to be using a fork of the same JSON framework that you are using.


Maybe looking at the Objective-C Runtime Reference could help you !

There are some functions (like class_createInstance and object_setInstanceVariable) that could help you.


You might want to checkout my implementation for serializing and deseriazling JSON to NSObjects and vice versa. - https://github.com/mahadevans87/OBJC_JSONSerializer