AnyJSON CocoaPods

Encode / Decode JSON By Any Means Possible

5 years after

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

BubbleWrap

BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa ...

mongokit

mongokit

MongoKit framework try to keep its simplicity when you manage mongodb in python. ...

any-json

any-json

Convert (almost) anything to JSON ...

durian

durian

Webhooks for Django *experimental* ...

daikon

daikon

ElasticSearch CLI ...


Top Contributors

mattt

Releases

-   0.0.1 zip tar