Encode / Decode JSON By Any Means Possible
Switch branches/tags
Nothing to show
Pull request Compare This branch is 34 commits behind mattt:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AnyJSON.h
AnyJSON.m
AnyJSON.podspec
LICENSE
README.md

README.md

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 preferNSJSONSerialization` 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.