AnyJSON CocoaPods

Encode / Decode JSON By Any Means Possible

AnyJSON

Encode / Decode JSON By Any Means Possible

What was once the most egregious part of AFNetworking has been spun off into its own library.

This is a library about getting things to work, because there are more important things that you have to do than futz around with an interchange format.

AnyJSON provides a function to encode and a function to decode JSON, using the first available of the following 3rd-party libraries:

If none of these libraries are included in the target, AnyJSON falls back on `NSJSONSerialization, if available. To prefer NSJSONSerialization and fall back on the first available 3rd-party framework, #define _ANYJSON_PREFER_NSJSONSERIALIZATION_somewhere in your project.

Why anyone can have such strong opinions about functionality that–in so many cases–accounts for such an insignificant percentage of overall runtime is a mystery. But sometimes it’s better not to press the issue, and just be as accommodating as you can. AnyJSON keeps the peace.

Usage

Decoding

NSData *data = [@"{\"foo\": 42}" dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
id JSON = AnyJSONDecode(data, &error);
if (error) {
  NSLog(@"Error: %@", error);
}

Encoding

NSArray *array = [NSArray arrayWithObjects:@"foo", @"bar", @"baz"];
NSError *error = nil;
NSData *data = AnyJSONEncode(array, &error);
if (error) {
  NSLog(@"Error: %@", error);
}

Contact

Mattt Thompson

License

AnyJSON is available under the MIT license. See the LICENSE file for more info.

Related Repositories

AnyJSON

AnyJSON

Encode / Decode JSON By Any Means Possible™ ...

anyjson

anyjson

[mirror] of Rune Halvorsen's AnyJSON Python module. ...

AnyJSON

AnyJSON

Encode / Decode JSON By Any Means Possible ...

json-bench

json-bench

Simple script using demjson and anyjson to benchmark some json libs ...


Top Contributors

mattt

Releases

-   0.0.1 zip tar