mattt/AnyJSON — pull request #1 by 0xced (2012-11-19 09:02:02+00:00)
Title: Dynamically implement the NSJSONSerialization API

Not to be pulled right now, just for discussion about this implementation.

This approach of dynamically creating the `NSJSONSerialization` class and rebinding it (i.e. the assembly stuff) has one big advantage over the `AnyJSONEncode` / `AnyJSONDecode` functions: you can drop the `AnyJSON.m` file in any app that use `NSJSONSerialization` and it will automatically work, even on iOS < 5. This even works for compiled static libraries using `NSJSONSerialization`.

On iOS 5+, this code does basically nothing. `objc_allocateClassPair` will fail and return `Nil`, so no AnyJSON* code will be executed at all.

TODO list:

* Update the README
* Translate the options parameters (both `NSJSONWritingOptions` and `NSJSONReadingOptions`) for each JSON library (what happens when the options can not be translated?)
* Implement `AnyJSONIsValidObject`, `AnyJSONEncodeStream` and `AnyJSONDecodeStream`